ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-08-04 03:39:32
Exec Total Coverage
Lines: 9206 12208 75.4%
Functions: 378 436 86.7%
Branches: 7305 12924 56.5%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1106239 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1106239 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1105962 times.
1106239 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1105962 times.
1105962 if (c < 0)
56 c -= val / 2;
57 1105962 else c += (val/2);
58 1105962 }
59 1106239 c -= c % val;
60 1106239 coord = c;
61 1106239 }
62
63 38391589 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 37874983 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38390374 times.
38391589 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38360054 times.
38390374 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38360054 times.
38360054 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38359988 times.
38360054 if (x > world_w+256) return true;
69 38359988 return false;
70 38391589 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 427 void identifyCFEnemies()
108 {
109 427 trapConstantHorizontalID=-1;
110 427 trapConstantVerticalID=-1;
111 427 trapLOSHorizontalID=-1;
112 427 trapLOSVerticalID=-1;
113 427 trapLOS4WayID=-1;
114 427 cornerTrapID=-1;
115 427 centerTrapID=-1;
116 427 rockID=-1;
117 427 zoraID=-1;
118 427 statueID=-1;
119
120
2/2
✓ Branch 0 taken 218624 times.
✓ Branch 1 taken 427 times.
219051 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 218203 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 421 times.
218624 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 421 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 218188 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 427 times.
218624 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 427 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 218197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
218624 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 427 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 218197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
218624 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 427 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 218197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
218624 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 427 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 218197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
218624 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 427 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 218197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
218624 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 427 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 218197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
218624 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 427 rockID=i;
140
4/4
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 218174 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 424 times.
218624 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 424 zoraID=i;
142
143
4/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 218134 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 427 times.
218624 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 427 statueID=i;
145 218624 }
146 427 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 209578 int32_t hero_on_wall()
211 {
212 209578 zfix lx = Hero.getX();
213 209578 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 187695 times.
✓ Branch 1 taken 21883 times.
✓ Branch 2 taken 8229 times.
✓ Branch 3 taken 179466 times.
209578 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 179237 times.
179466 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 178960 times.
179237 if(ly==world_h-48) return down+1;
220 178960 }
221
222
4/4
✓ Branch 0 taken 192305 times.
✓ Branch 1 taken 16767 times.
✓ Branch 2 taken 21070 times.
✓ Branch 3 taken 171235 times.
209072 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 171015 times.
171235 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 170914 times.
✓ Branch 1 taken 101 times.
171015 if(lx==world_w-48) return right+1;
227 170914 }
228
229 208751 return 0;
230 209578 }
231
232 805958 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600237 times.
✓ Branch 1 taken 205721 times.
805958 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4001923 bool enemy::overpit(enemy *e)
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37027966 times.
✓ Branch 1 taken 3982721 times.
41010687 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37008764 times.
37027966 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37008764 }
256 }
257 3982721 return false;
258 4001923 }
259
260 12277818 bool enemy::shadow_overpit(enemy *e)
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 176358486 times.
✓ Branch 1 taken 12251357 times.
188609843 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 176332025 times.
176358486 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 26461 return true;
271 }
272 176332025 }
273 }
274 12251357 return false;
275 12277818 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7404823 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7404823 times.
7404823 if(moveflags & move_ignore_blockflags) return false;
281 7404823 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4872967 times.
✓ Branch 1 taken 2531856 times.
✓ Branch 2 taken 1389095 times.
✓ Branch 3 taken 1142761 times.
9936679 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2513532 times.
✓ Branch 1 taken 4891291 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2513532 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7404823 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2573086 times.
✓ Branch 1 taken 4831737 times.
✓ Branch 2 taken 2571209 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2571209 times.
✗ Branch 5 not taken.
14810402 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2571209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2571209 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2422461 times.
✓ Branch 5 taken 148748 times.
2571209 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2565933 times.
✓ Branch 1 taken 2417185 times.
148748 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2563263 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2563016 times.
✓ Branch 3 taken 247 times.
2565933 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2562198 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2562132 times.
✓ Branch 3 taken 66 times.
2563016 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2551506 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5123969 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1987179 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2561837 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2575719 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8658129 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8658129 times.
8658129 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6563432 times.
✓ Branch 1 taken 2094697 times.
✓ Branch 2 taken 1745919 times.
✓ Branch 3 taken 348778 times.
10752826 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6577939 times.
✓ Branch 1 taken 2080190 times.
✓ Branch 2 taken 2080190 times.
✗ Branch 3 not taken.
10738319 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1196955 times.
✓ Branch 1 taken 7461174 times.
16119303 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7451034 times.
✓ Branch 1 taken 10140 times.
7461174 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7450915 times.
✓ Branch 1 taken 119 times.
7451034 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7450744 times.
✓ Branch 1 taken 171 times.
7450915 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7450489 times.
✓ Branch 1 taken 255 times.
7450744 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242527 times.
✓ Branch 1 taken 6207962 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238523 times.
14896974 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6198373 times.
✓ Branch 1 taken 1248112 times.
7446485 (pit_blocks && ispitfall(dx,dy))));
309 8658129 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 281915 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 281915 int32_t c = COMBOTYPE(dx,dy);
314 281915 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35530 times.
✓ Branch 1 taken 246385 times.
281915 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 281895 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281778 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281778 times.
✗ Branch 5 not taken.
1062405 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281778 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249929 times.
✓ Branch 5 taken 31849 times.
281778 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281205 times.
✓ Branch 1 taken 249356 times.
31849 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280818 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280787 times.
✓ Branch 3 taken 31 times.
281205 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277132 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276857 times.
✓ Branch 3 taken 275 times.
280787 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275813 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553675 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223650 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276818 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139610 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137287 times.
✓ Branch 1 taken 2323 times.
139610 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139610 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139610 times.
279220 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139513 times.
✓ Branch 1 taken 97 times.
139610 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139508 times.
✓ Branch 1 taken 5 times.
139513 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139499 times.
✓ Branch 1 taken 9 times.
139508 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139470 times.
✓ Branch 1 taken 29 times.
139499 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137149 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278690 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137149 times.
✓ Branch 1 taken 2071 times.
139220 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114747 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114747 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114747 times.
✗ Branch 9 not taken.
229494 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 114747 {
344
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 x=X;
345
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 y=Y;
346
3/6
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114747 times.
✗ Branch 5 not taken.
114747 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 114747 id=Id;
348 114747 clk=Clk;
349
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 floor_y=y;
350 114747 ceiling=false;
351 114747 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 114747 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114747 times.
✓ Branch 2 taken 114747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114747 times.
✗ Branch 5 not taken.
114747 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 114747 did_armos=true;
355 114747 script_spawned=false;
356
357 114747 d = guysbuf + (id & 0xFFF);
358 114747 hp = d->hp;
359 114747 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 114747 flags=d->flags;
364 114747 flags=d->flags;
365 114747 s_tile=d->s_tile; //secondary (additional) tile(s)
366 114747 family=d->family;
367 114747 dcset=d->cset;
368 114747 cs=dcset;
369
2/2
✓ Branch 0 taken 88603 times.
✓ Branch 1 taken 26144 times.
114747 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 114747 dp=d->dp;
371 114747 wdp=d->wdp;
372 114747 wpn=d->weapon;
373 114747 wpnsprite = d-> wpnsprite; //2.6 -Z
374 114747 rate=d->rate;
375 114747 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 dstep=d->step;
377 114747 homing=d->homing;
378 114747 dmisc1=d->attributes[0];
379 114747 dmisc2=d->attributes[1];
380 114747 dmisc3=d->attributes[2];
381 114747 dmisc4=d->attributes[3];
382 114747 dmisc5=d->attributes[4];
383 114747 dmisc6=d->attributes[5];
384 114747 dmisc7=d->attributes[6];
385 114747 dmisc8=d->attributes[7];
386 114747 dmisc9=d->attributes[8];
387 114747 dmisc10=d->attributes[9];
388 114747 dmisc11=d->attributes[10];
389 114747 dmisc12=d->attributes[11];
390 114747 dmisc13=d->attributes[12];
391 114747 dmisc14=d->attributes[13];
392 114747 dmisc15=d->attributes[14];
393 114747 dmisc16=d->attributes[15];
394 114747 dmisc17=d->attributes[16];
395 114747 dmisc18=d->attributes[17];
396 114747 dmisc19=d->attributes[18];
397 114747 dmisc20=d->attributes[19];
398 114747 dmisc21=d->attributes[20];
399 114747 dmisc22=d->attributes[21];
400 114747 dmisc23=d->attributes[22];
401 114747 dmisc24=d->attributes[23];
402 114747 dmisc25=d->attributes[24];
403 114747 dmisc26=d->attributes[25];
404 114747 dmisc27=d->attributes[26];
405 114747 dmisc28=d->attributes[27];
406 114747 dmisc29=d->attributes[28];
407 114747 dmisc30=d->attributes[29];
408 114747 dmisc31=d->attributes[30];
409 114747 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4275 times.
✓ Branch 1 taken 110472 times.
114747 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110472 dmisc31 = dmisc32;
413 110472 dmisc32 = 0;
414 110472 }
415 114747 spr_shadow=d->spr_shadow;
416 114747 spr_death=d->spr_death;
417 114747 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4704627 times.
✓ Branch 1 taken 114747 times.
4819374 for(int32_t i=0; i<edefLAST255; i++)
420 4704627 defense[i]=d->defense[i];
421
422 114747 bgsfx=d->bgsfx;
423 114747 hitsfx=d->hitsfx;
424 114747 deadsfx=d->deadsfx;
425 114747 bosspal=d->bosspal;
426
427 114747 frozentile = d->frozentile;
428
429 114747 frozencset = d->frozencset;
430 114747 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1147470 times.
✓ Branch 1 taken 114747 times.
1262217 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 1950699 times.
✓ Branch 1 taken 114747 times.
2065446 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 114747 isCore = true; //t.b.a
436 114747 parentCore = 0; //t.b.a
437
438 114747 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3671904 times.
✓ Branch 1 taken 114747 times.
3786651 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3671904 times.
✓ Branch 1 taken 114747 times.
3786651 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 114747 script = d->script;
443
444
2/2
✓ Branch 0 taken 917976 times.
✓ Branch 1 taken 114747 times.
1032723 for ( int32_t q = 0; q < 8; q++ )
445 {
446 917976 initD[q] = d->initD[q];
447 917976 }
448
449 114747 stickclk = 0;
450 114747 submerged = false;
451 114747 didScriptThisFrame = false;
452 114747 ffcactivated = std::nullopt;
453 114747 hitdir = -1;
454 114747 editorflags = d->editorflags; //set by Enemy Editor
455 //Set the drawing flag for this sprite.
456
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
457
458
459
2/2
✓ Branch 0 taken 8916 times.
✓ Branch 1 taken 105831 times.
114747 if(bosspal>-1)
460 {
461
1/2
✓ Branch 0 taken 8916 times.
✗ Branch 1 not taken.
8916 loadpalset(csBOSS,pSprite(bosspal));
462 8916 }
463
464
2/2
✓ Branch 0 taken 50309 times.
✓ Branch 1 taken 64438 times.
114747 if(bgsfx>-1)
465 {
466
1/2
✓ Branch 0 taken 50309 times.
✗ Branch 1 not taken.
50309 cont_sfx(bgsfx);
467 50309 }
468
469
2/2
✓ Branch 0 taken 88603 times.
✓ Branch 1 taken 26144 times.
114747 if(get_qr(qr_NEWENEMYTILES))
470 {
471 88603 o_tile=d->e_tile;
472 88603 frate = d->e_frate;
473 88603 }
474 else
475 {
476 26144 o_tile=d->tile;
477 26144 frate = d->frate;
478 }
479
480 114747 tile=0; //init to 0 here, but set it later.
481
482 114747 scripttile = -1;
483 114747 scriptflip = -1;
484 114747 do_animation = true;
485 114747 immortal = false;
486 114747 noSlide = false;
487 114747 deathexstate = -1;
488
489 114747 hashero=false;
490
491 // If they forgot the invisibility flag, here's another failsafe:
492
4/4
✓ Branch 0 taken 5742 times.
✓ Branch 1 taken 109005 times.
✓ Branch 2 taken 5648 times.
✓ Branch 3 taken 94 times.
114747 if(o_tile==0 && family!=eeSPINTILE)
493
1/2
✓ Branch 0 taken 5648 times.
✗ Branch 1 not taken.
5648 flags |= guy_invisible;
494
495 // step = d->step/100.0;
496 // To preserve the odd step values for Keese & Gleeok heads. -L
497
5/8
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12229 times.
✓ Branch 5 taken 102518 times.
✓ Branch 6 taken 12229 times.
✗ Branch 7 not taken.
114747 if(dstep==62.0) dstep+=0.5;
498
5/8
✓ Branch 0 taken 102518 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102518 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 694 times.
✓ Branch 5 taken 101824 times.
✓ Branch 6 taken 694 times.
✗ Branch 7 not taken.
102518 else if(dstep==89) dstep-=1/9;
499
500
5/10
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114747 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114747 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114747 times.
✗ Branch 9 not taken.
114747 step = zslongToFix(dstep*100);
501
502
503 114747 item_set = d->item_set;
504 114747 grumble = d->grumble;
505
506
2/2
✓ Branch 0 taken 89978 times.
✓ Branch 1 taken 24769 times.
114747 if(frate == 0)
507 24769 frate = 256;
508
509 114747 leader = itemguy = dying = scored = false;
510 114747 canfreeze = count_enemy = true;
511
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 mainguy = !(flags & guy_doesnt_count);
512
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 dir = zc_oldrand()&3;
513
514 //2.6 Enemy Editor Hit and TIle Sizes
515
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114738 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114747 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
516 // al_trace("Enemy txsz:%i\n", txsz);
517
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114738 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114747 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
518
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114740 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114747 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
519
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114740 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114747 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114747 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114747 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
521
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
522
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
523 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114747 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114747 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114747 times.
114747 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
526 {
527 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
528 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
529 }
530
531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114747 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114747 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
532
533 114747 SIZEflags = d->SIZEflags;
534
535
8/10
✓ Branch 0 taken 114498 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114381 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
114747 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
536 1 wpn = 0;
537
538 //tile should never be 0 after init --Z (failsafe)
539
4/6
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107505 times.
✓ Branch 5 taken 7242 times.
114747 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
540
541 //Moveflags; for gravity and pit interaction
542 114747 moveflags = d->moveflags;
543
3/4
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17673 times.
✓ Branch 3 taken 97074 times.
114747 if(!can_pitfall(false))
544 {
545 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
546
2/4
✓ Branch 0 taken 17673 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17673 times.
✗ Branch 3 not taken.
17673 moveflags &= ~move_can_pitfall;
547
2/4
✓ Branch 0 taken 17673 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17673 times.
✗ Branch 3 not taken.
17673 moveflags &= ~move_can_waterdrown;
548 17673 }
549
550 114747 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
551
552 114747 specialsfx = d->specialsfx;
553
1/2
✓ Branch 0 taken 114747 times.
✗ Branch 1 not taken.
114747 weap_data = d->weap_data;
554 114747 }
555
556 114492 enemy::~enemy()
557 114492 {
558
2/4
✓ Branch 0 taken 114492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114492 times.
✗ Branch 3 not taken.
114492 FFCore.destroyScriptableObject(ScriptType::NPC, getUID());
559
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114479 times.
114492 if(hashero)
560 {
561
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
562 13 hashero=false;
563 13 }
564 114492 }
565
566 bool enemy::is_move_paused()
567 {
568 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
569 }
570
571 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
572 {
573 7024 int32_t yg = (special==spw_floater)?8:0;
574 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
575
576
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
577 input_x = dx;
578
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
579 input_y = dy;
580
581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
582
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
583
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
584 return true;
585
586
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
587 {
588 if(ispitfall(dx,dy))
589 return true;
590 }
591
592 7024 bool flying = false;
593 7024 bool cansolid = false;
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
595 cansolid = true;
596
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
597 {
598 case spw_clipbottomright:
599 if(dy>=128 || dx>=208) return true;
600 break;
601 case spw_clipright:
602 break; //if(input_x>=208) return true; break;
603
604 case spw_wizzrobe: // fall through
605 case spw_floater: // Special case for fliers and wizzrobes - hack!
606 {
607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
608 {
609 if(dy < 32-yg || dy >= 144) return true;
610 if(dx < 32 || dx >= 224) return true;
611 }
612
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
613 return true;
614 317 cansolid = true;
615 317 flying = true;
616 }
617 317 }
618
619 7024 dx = TRUNCATE_HALF_TILE(dx);
620 7024 dy = TRUNCATE_HALF_TILE(dy);
621
622
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
623
624
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
625 return !(moveflags & move_ignore_screenedge);
626
627 // TODO: could this reuse _walkflag?
628
629 //_walkflag code
630 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
631
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
632
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
633
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
634
4/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 383 times.
✓ Branch 3 taken 655 times.
7024 if (!s2 || !s2->valid) s2 = s0;
635
636 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
637
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
638 7024 newcombo c = combobuf[ci];
639
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
641
642 7024 int32_t b=1;
643
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
644
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
651
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
652
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
653
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
654
655
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
656
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
657
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
658
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
659
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
660
661
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
662 {
663 6707 int32_t cwalkflag = c.walk & 0xF;
664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
666 {
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 6707 else cwalkflag |= c1.walk & 0xF;
678 6707 }
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
680 {
681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
682 {
683 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 int efflag = (c2.walk & 0xF0)>>4;
686 int newsolid = (c2.walk & 0xF);
687 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 }
689 else cwalkflag &= c2.walk;
690 }
691 6707 else cwalkflag |= c2.walk & 0xF;
692 6707 }
693
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
694 239 return true;
695 6468 }
696
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
705 return true;
706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
707 return true;
708
709 6785 return false;
710 7024 }
711
712 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
715 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
718 {
719 if((moveflags & move_obeys_grav) && isSideViewGravity())
720 return false;
721 }
722
723
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
724
725
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
726 {
727
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
728 {
729
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 770 int mx = (bx+dx).getFloor();
731
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 return false;
735 2976 }
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 return false;
738
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 return false;
740 770 }
741 else
742 {
743 341 int mx = (rx+dx).getCeil();
744 341 int lx = mx-hit_width+1;
745
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 1 return false;
749 2141 }
750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 return false;
752
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 1110 }
756
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
757 {
758
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
759 {
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
761 315 int my = (by+dy).getFloor();
762
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 238 return false;
766 154 }
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 return false;
769
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 77 }
772 else
773 {
774 109 int my = (ry+dy).getCeil();
775 109 int ly = my-hit_height+1;
776
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 return false;
780 218 }
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 return false;
783
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 186 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 1296 return true;
792 1535 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 1311 bool ret = true;
836
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
837 dy = 0;
838 1311 const int scl = 2;
839
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
840 {
841
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
842 {
843 260 int32_t tdx = dx.sign() * scl;
844
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 260 dx -= tdx;
846 else
847 {
848 if(earlyret) return false;
849 dx = tdx;
850 ret = false;
851 }
852 260 }
853 else
854 {
855 34 int32_t tdy = dy.sign() * scl;
856
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 27 dy -= tdy;
858 else
859 {
860
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
861 7 dy = tdy;
862 7 ret = false;
863 }
864 }
865 }
866
867
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
868 {
869
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 1110 x += dx;
871 else
872 {
873
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
874 ret = false;
875 int xsign = dx.sign();
876 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 x += xsign;
879 dx -= xsign;
880 }
881 if(dx)
882 {
883 dx.doDecBound(0,-9999, 0,9999);
884 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 retval = val;
888 return BSEARCH_CONTINUE_AWAY0;
889 }
890 else return BSEARCH_CONTINUE_TOWARD0;
891 });
892 x += dx;
893 }
894 }
895 1110 }
896
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
897 {
898
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
899 186 y += dy;
900 else
901 {
902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
903 14 ret = false;
904 14 int ysign = dy.sign();
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 y += ysign;
908 dy -= ysign;
909 }
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
911 {
912 14 dy.doDecBound(0,-9999, 0,9999);
913
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 retval = val;
917 return BSEARCH_CONTINUE_AWAY0;
918 }
919 210 else return BSEARCH_CONTINUE_TOWARD0;
920 210 });
921 14 y += dy;
922 14 }
923 }
924 200 }
925 1310 return ret;
926 1311 }
927
928 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
931
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 16 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 479 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 259 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 754 }
952
953 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 double v = degrees.getFloat() * PI / 180.0;
956 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 754 zfix tx = x, ty = y;
971 754 bool ret = moveDir(dir, px, special, kb, true);
972 754 x = tx;
973 754 y = ty;
974 754 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 37842804 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 37840437 times.
✓ Branch 1 taken 2367 times.
37842804 if(fallclk > 0)
989 {
990
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
991
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
998 never_return(screen_spawned, index);
999
1000
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 11 stop_bgsfx(index);
1005 11 return true;
1006 }
1007 else
1008 {
1009 11 try_death(true); //Force death
1010 11 ++fallclk; //force another frame of falling
1011 }
1012 11 }
1013
1014 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 2356 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1018 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 2356 }
1021 37842793 return false;
1022 37842804 }
1023
1024 // Handle drowning in water
1025 37840437 bool enemy::do_drowning(int32_t index)
1026 {
1027
1/2
✓ Branch 0 taken 37840437 times.
✗ Branch 1 not taken.
37840437 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1030 //!TODO: Drown SFX
1031 if(!--drownclk)
1032 {
1033 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035 else if(dying) //Give 1 frame for script revival
1036 {
1037 if(flags&guy_never_return)
1038 never_return(screen_spawned, index);
1039
1040 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 stop_bgsfx(index);
1045 return true;
1046 }
1047 else
1048 {
1049 try_death(true); //Force death
1050 ++drownclk; //force another frame of falling
1051 }
1052 }
1053
1054 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1055 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1056 cs = spr.csets & 0xF;
1057 int32_t fr = spr.frames ? spr.frames : 1;
1058 int32_t spd = spr.speed ? spr.speed : 1;
1059 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 }
1062 37840437 return false;
1063 37840437 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 38503485 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38501656 times.
38503485 if(immortal)
1071 {
1072 1829 dying = false;
1073 1829 return false;
1074 }
1075
2/2
✓ Branch 0 taken 763072 times.
✓ Branch 1 taken 37738584 times.
38501656 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 763071 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
763072 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(screen_spawned, 1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 763072 --clk2;
1083
1084
4/4
✓ Branch 0 taken 723152 times.
✓ Branch 1 taken 39920 times.
✓ Branch 2 taken 38569 times.
✓ Branch 3 taken 3242 times.
763072 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41811 times.
✓ Branch 1 taken 681341 times.
723152 && hp>-1000) // not killed by ringleader
1086 38569 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 719705 times.
✓ Branch 1 taken 43367 times.
763072 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 42665 times.
✓ Branch 1 taken 702 times.
43367 if(flags&guy_never_return)
1091 702 never_return(screen_spawned, index);
1092
1093
2/2
✓ Branch 0 taken 43296 times.
✓ Branch 1 taken 71 times.
43367 if(leader)
1094 71 kill_em_all();
1095
1096 43367 leave_item();
1097 43367 }
1098
1099 763072 stop_bgsfx(index);
1100 763072 return (clk2==0);
1101 }
1102
1103 37738584 return false;
1104 38503485 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 37843060 bool enemy::animate(int32_t index)
1110 {
1111
2/2
✓ Branch 0 taken 1708646 times.
✓ Branch 1 taken 36134414 times.
37843060 if(sclk <= 0) hitdir = -1;
1112
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37842804 times.
37843060 if(switch_hooked)
1113 {
1114
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1115 {
1116 //Run its script
1117 if (!didScriptThisFrame)
1118 {
1119 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1120 {
1121 return 0; //Avoid NULLPO if this object deleted itself
1122 }
1123 }
1124 }
1125 256 return false;
1126 }
1127
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37842793 times.
37842804 if(do_falling(index)) return true;
1128
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 37840437 times.
37842793 else if(fallclk)
1129 {
1130 //clks
1131
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1132 704 --hclk;
1133
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1134 --stunclk;
1135
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1136 --frozenclock;
1137
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1138 {
1139 Hero.setX(x);
1140 Hero.setY(y);
1141 Hero.fallCombo = fallCombo;
1142 Hero.fallclk = fallclk;
1143
1144 if(hashero)
1145 {
1146 hashero = false; //Let Hero go if falling
1147 Hero.setEaten(0);
1148 }
1149 }
1150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1151 {
1152 2356 run_script(MODE_NORMAL);
1153 2356 }
1154 2356 return false;
1155 }
1156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37840437 times.
37840437 if(do_drowning(index)) return true;
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37840437 times.
37840437 else if(drownclk)
1158 {
1159 //clks
1160 if(hclk>0)
1161 --hclk;
1162 if(stunclk>0)
1163 --stunclk;
1164 if ( frozenclock > 0 )
1165 --frozenclock;
1166 if(hashero)
1167 {
1168 Hero.setX(x);
1169 Hero.setY(y);
1170 Hero.drownclk = drownclk;
1171
1172 if(hashero)
1173 {
1174 hashero = false; //Let Hero go if falling
1175 Hero.setEaten(0);
1176 }
1177 }
1178 if (!didScriptThisFrame)
1179 {
1180 run_script(MODE_NORMAL);
1181 }
1182 return false;
1183 }
1184 37840437 int32_t nx = real_x(x);
1185 37840437 int32_t ny = real_y(y);
1186
1187
4/4
✓ Branch 0 taken 27372837 times.
✓ Branch 1 taken 10467600 times.
✓ Branch 2 taken 5641111 times.
✓ Branch 3 taken 21731726 times.
37840437 if(ox!=nx || oy!=ny)
1188 {
1189 16108711 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1190 16108711 }
1191
1192 37840437 ox = nx;
1193 37840437 oy = ny;
1194
1195 // Maybe they fell off the bottom in sideview, or were moved by a script.
1196
1197 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1198
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37838608 times.
37840437 if ( immortal )
1199 {
1200 //skip, as it can go out of bounds, from immortality
1201 1829 }
1202
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37838608 times.
✓ Branch 2 taken 37838608 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37838608 times.
37838608 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1203 {
1204 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1205 }
1206
2/2
✓ Branch 0 taken 37807007 times.
✓ Branch 1 taken 31601 times.
37838608 else if (OUTOFBOUNDS(id, x, y))
1207 {
1208 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1209 31601 }
1210 //fall down
1211
6/6
✓ Branch 0 taken 27023676 times.
✓ Branch 1 taken 10816761 times.
✓ Branch 2 taken 10546498 times.
✓ Branch 3 taken 27293939 times.
✓ Branch 4 taken 511441 times.
✓ Branch 5 taken 10035057 times.
37840437 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1212 {
1213
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9647359 times.
10035057 if(isSideViewGravity())
1214 {
1215
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1216 {
1217
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1218 {
1219 157378 bool willHitSVPlatform = false;
1220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1222
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1223 {
1224
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1225 {
1226 willHitSVPlatform = true;
1227 break;
1228 }
1229 157378 }
1230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1231 {
1232 y+=fall/100;
1233 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1234 do_fix(y, 16); //Fix to top of SV Ladder
1235 fall = 0;
1236 }
1237 else
1238 {
1239 157378 y+=fall/100;
1240
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= (int32_t)zinit.terminalv)
1241 139566 fall += (zinit.gravity/100);
1242 }
1243 157378 }
1244 else
1245 {
1246
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1247 {
1248 //y-=(int32_t)y%8; // Fix position
1249 277 do_fix(y, 8); //Fix position
1250 277 }
1251
1252 230320 fall = 0;
1253 }
1254 387698 }
1255 else
1256 {
1257 if(isOnSideviewPlatform())
1258 fall = 0;
1259 else
1260 {
1261 zfix fall_amnt = fall/100;
1262 bool hit = false;
1263 while(fall_amnt >= 1)
1264 {
1265 --fall_amnt;
1266 ++y;
1267 if(isOnSideviewPlatform())
1268 {
1269 y = y.getInt();
1270 fall_amnt = 0;
1271 hit = true;
1272 break;
1273 }
1274 }
1275 if(fall_amnt > 0)
1276 y += fall_amnt;
1277 if(fall_amnt < 0)
1278 {
1279 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1280 hit = true;
1281 }
1282 if(hit)
1283 fall = 0;
1284 else if(fall <= (int32_t)zinit.terminalv)
1285 fall += (zinit.gravity/100);
1286 }
1287 }
1288 387698 }
1289 else
1290 {
1291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_fake_z))
1292 {
1293
2/2
✓ Branch 0 taken 5079296 times.
✓ Branch 1 taken 4568063 times.
9647359 if(fakefall!=0)
1294 4568063 fakez-=(fakefall/100);
1295
1296
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5079296 times.
9647359 if(fakez<0)
1297 4568063 fakez = fakefall = 0;
1298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5079296 times.
5079296 else if(fakefall <= (int32_t)zinit.terminalv)
1299 5079296 fakefall += (zinit.gravity/100);
1300
1301
5/6
✓ Branch 0 taken 9647359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5079296 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 496986 times.
9647359 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1302 9647359 }
1303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_real_z))
1304 {
1305
2/2
✓ Branch 0 taken 5512182 times.
✓ Branch 1 taken 4135177 times.
9647359 if(fall!=0)
1306 4135177 z-=(fall/100);
1307
1308
2/2
✓ Branch 0 taken 4120605 times.
✓ Branch 1 taken 5526754 times.
9647359 if(z<0)
1309 4120605 z = fall = 0;
1310
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5516697 times.
5526754 else if(fall <= (int32_t)zinit.terminalv)
1311 5516697 fall += (zinit.gravity/100);
1312
1313
6/6
✓ Branch 0 taken 9605145 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5484540 times.
✓ Branch 3 taken 4120605 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 493851 times.
9647359 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1314 9647359 }
1315
1316 }
1317 10035057 }
1318
4/4
✓ Branch 0 taken 37324970 times.
✓ Branch 1 taken 515467 times.
✓ Branch 2 taken 9226940 times.
✓ Branch 3 taken 28098030 times.
37840437 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1319 {
1320
8/10
✓ Branch 0 taken 9200269 times.
✓ Branch 1 taken 26671 times.
✓ Branch 2 taken 9160611 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9160611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9200269 times.
✓ Branch 8 taken 9160611 times.
✓ Branch 9 taken 9160611 times.
9226940 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1321 {
1322 9160611 fallCombo = check_pits();
1323 9160611 }
1324 27548162 }
1325
4/4
✓ Branch 0 taken 37324970 times.
✓ Branch 1 taken 18836689 times.
✓ Branch 2 taken 146897 times.
✓ Branch 3 taken 37178073 times.
56161659 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1326 {
1327
8/10
✓ Branch 0 taken 142951 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141898 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142951 times.
✓ Branch 8 taken 141898 times.
✓ Branch 9 taken 141898 times.
146897 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1328 {
1329 141898 drownCombo = check_water();
1330 141898 }
1331 430693 }
1332
1333 56445455 runKnockback(); //scripted knockback handling
1334
1335 // clk is incremented here
1336
2/2
✓ Branch 0 taken 54147805 times.
✓ Branch 1 taken 2297650 times.
56445455 if(++clk >= frate)
1337 2297650 clk=0;
1338
1339 // hit and death handling
1340
2/2
✓ Branch 0 taken 1249563 times.
✓ Branch 1 taken 55195892 times.
56445455 if(hclk>0)
1341 1249563 --hclk;
1342
1343
2/2
✓ Branch 0 taken 673725 times.
✓ Branch 1 taken 55771730 times.
56445455 if(stunclk>0)
1344 673725 --stunclk;
1345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56445455 times.
56445455 if ( frozenclock > 0 )
1346 --frozenclock;
1347
1348
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 56430579 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
56445455 if(ceiling && z <= 0 && fakez <= 0)
1349 124 ceiling = false;
1350
1351 56445455 try_death();
1352
1353 56445455 scored=false;
1354
1355 56445455 ++c_clk;
1356
1357 //Run its script
1358
2/2
✓ Branch 0 taken 18629835 times.
✓ Branch 1 taken 37815620 times.
56445455 if (!didScriptThisFrame)
1359 {
1360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37815620 times.
37815620 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1361 {
1362 return 0; //Avoid NULLPO if this object deleted itself
1363 }
1364 37815620 }
1365
1366 // returns true when enemy is defeated
1367 56445455 return Dead(index);
1368 56448078 }
1369
1370 38590565 bool enemy::setSolid(bool set)
1371 {
1372
1/2
✓ Branch 0 taken 38590565 times.
✗ Branch 1 not taken.
38590565 bool actual = set && !isSubmerged();
1373 38590565 bool ret = solid_object::setSolid(actual);
1374 38590565 solid = set;
1375 38590565 return ret;
1376 }
1377 void enemy::doContactDamage(int32_t hdir)
1378 {
1379 Hero.hithero(guys.find(this), hdir);
1380 }
1381
1382 22405 void enemy::solid_push(solid_object *obj)
1383 {
1384
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1386 22405 zfix dx, dy;
1387 22405 int32_t hdir = -1;
1388 22405 solid_push_int(obj,dx,dy,hdir,true);
1389
1390
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1391
1392 263 bool t = obj->getTempNonsolid();
1393 263 obj->setTempNonsolid(true);
1394
1395 263 int32_t ydir = dy > 0 ? down : up;
1396 263 int32_t xdir = dx > 0 ? right : left;
1397
1398 263 auto special = isflier(id) ? spw_floater : spw_none;
1399
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1400 {
1401 //Crushed?
1402 7 }
1403
1404 263 obj->setTempNonsolid(t);
1405 22405 }
1406 22405 bool enemy::is_unpushable() const
1407 {
1408 22405 return isSubmerged();
1409 }
1410 22087 bool enemy::sideview_mode() const
1411 {
1412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1413 }
1414
1415 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1416 {
1417 3234 int32_t yg = (special==spw_floater)?8:0;
1418 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1419
1420
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1421 4732 return true;
1422
1423 3238 bool isInDungeon = isdungeon(screen_spawned);
1424
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1425 {
1426
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1427 1199 return true;
1428
1429
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1430
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1431 return true;
1432 595 }
1433
1434
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1435 {
1436
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1437
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1438 return true;
1439 62 }
1440
1441
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1442 {
1443 case spw_clipbottomright:
1444 if(dy>=128 || dx>=208) return true;
1445 break;
1446 case spw_clipright:
1447 break; //if(x>=208) return true; break;
1448
1449 case spw_wizzrobe: // fall through
1450 case spw_floater: // Special case for fliers and wizzrobes - hack!
1451 {
1452
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1453 {
1454
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1455
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1456 595 }
1457 857 return false;
1458 }
1459 }
1460
1461 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1462 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1463
1464 if(special==spw_water)
1465 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1466
1467 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1468 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1469 870 }
1470
1471 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1472 {
1473 6575 bool kb = false;
1474 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1475
1476
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1477 return true;
1478
1479
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1480 {
1481
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1482 return true;
1483
1484
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1485 return true;
1486 1513 }
1487
1488
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1489 {
1490
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1491
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1492 return true;
1493 6575 }
1494
1495
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1496 {
1497
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1499 }
1500 else
1501 {
1502
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1503
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1504
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1506 }
1507 6575 }
1508
1509 // returns true if cannot walk
1510 32379402 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1511 {
1512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32379402 times.
32379402 if(moveflags & move_new_movement)
1513 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1514 32379402 int32_t yg = (special==spw_floater)?8:0;
1515 32379402 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1516
2/2
✓ Branch 0 taken 3708329 times.
✓ Branch 1 taken 28671073 times.
32379402 switch(dir)
1517 {
1518 case l_down:
1519 case r_down:
1520 case down:
1521 case 11: //r_down
1522 case 12: //down
1523 case 13: //l_down
1524 {
1525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3708329 times.
3708329 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1526 {
1527
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3708321 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3708329 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1528 {
1529 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1530
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1531 8 }
1532 3708329 }
1533 3708329 break;
1534 }
1535 }
1536
2/2
✓ Branch 0 taken 3707233 times.
✓ Branch 1 taken 28672169 times.
32379402 switch(dir)
1537 {
1538 case r_up:
1539 case r_down:
1540 case right:
1541 case 9: //r_up
1542 case 10: //right
1543 case 11: //r_down
1544 {
1545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3707233 times.
3707233 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1546 {
1547
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3707230 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3707233 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1548 {
1549 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1550
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1551 3 }
1552 3707233 }
1553 3707233 break;
1554 }
1555 }
1556
1557
10/10
✓ Branch 0 taken 22326755 times.
✓ Branch 1 taken 10052647 times.
✓ Branch 2 taken 8703250 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10015648 times.
✓ Branch 5 taken 36999 times.
✓ Branch 6 taken 9992543 times.
✓ Branch 7 taken 23105 times.
✓ Branch 8 taken 22379401 times.
✓ Branch 9 taken 32371944 times.
32379402 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1558 44766260 return true;
1559
1560 32371944 bool isInDungeon = isdungeon(screen_spawned);
1561
4/4
✓ Branch 0 taken 3947541 times.
✓ Branch 1 taken 28424403 times.
✓ Branch 2 taken 11334 times.
✓ Branch 3 taken 3936207 times.
32371944 if(isInDungeon || special==spw_wizzrobe)
1562 {
1563
8/8
✓ Branch 0 taken 5870539 times.
✓ Branch 1 taken 22565198 times.
✓ Branch 2 taken 5647380 times.
✓ Branch 3 taken 223159 times.
✓ Branch 4 taken 5799126 times.
✓ Branch 5 taken 16989231 times.
✓ Branch 6 taken 5798939 times.
✓ Branch 7 taken 187 times.
28435737 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1564 11446319 return true;
1565
1566
8/8
✓ Branch 0 taken 5719003 times.
✓ Branch 1 taken 11270415 times.
✓ Branch 2 taken 5555828 times.
✓ Branch 3 taken 163175 times.
✓ Branch 4 taken 5668956 times.
✓ Branch 5 taken 5764634 times.
✓ Branch 6 taken 5668002 times.
✓ Branch 7 taken 954 times.
16989418 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1567
2/2
✓ Branch 0 taken 112080 times.
✓ Branch 1 taken 94 times.
11223830 if(special!=spw_door) // walk in door way
1568 112080 return true;
1569 5765682 }
1570
1571
6/6
✓ Branch 0 taken 3088221 times.
✓ Branch 1 taken 6613668 times.
✓ Branch 2 taken 750728 times.
✓ Branch 3 taken 2337493 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699498 times.
9701889 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1572 {
1573
4/4
✓ Branch 0 taken 3030574 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3029622 times.
6066663 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1574
4/4
✓ Branch 0 taken 3030391 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3029672 times.
✓ Branch 3 taken 719 times.
3030574 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1575 7369 return true;
1576 3029622 }
1577
1578
4/4
✓ Branch 0 taken 7521852 times.
✓ Branch 1 taken 2166414 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9694520 switch(special)
1579 {
1580 case spw_clipbottomright:
1581
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1582 707 break;
1583 case spw_clipright:
1584 5281 break; //if(input_x>=208) return true; break;
1585
1586 case spw_wizzrobe: // fall through
1587 case spw_floater: // Special case for fliers and wizzrobes - hack!
1588 {
1589
2/2
✓ Branch 0 taken 2889195 times.
✓ Branch 1 taken 4632657 times.
7521852 if(isInDungeon)
1590 {
1591
3/4
✓ Branch 0 taken 4632645 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4632645 times.
4632657 if(dy < 32-yg || dy >= world_h-32) return true;
1592
4/4
✓ Branch 0 taken 4630559 times.
✓ Branch 1 taken 2086 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4630543 times.
4632645 if(dx < 32 || dx >= world_w-32) return true;
1593 4630543 }
1594 7519738 return false;
1595 }
1596 }
1597
1598 2172402 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1599
2/2
✓ Branch 0 taken 483876 times.
✓ Branch 1 taken 1688526 times.
2172402 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1600
1601
2/2
✓ Branch 0 taken 413873 times.
✓ Branch 1 taken 1758529 times.
2172402 if(special==spw_water)
1602
2/2
✓ Branch 0 taken 16718 times.
✓ Branch 1 taken 397155 times.
413873 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1603
1604
2/2
✓ Branch 0 taken 1698580 times.
✓ Branch 1 taken 59949 times.
1758529 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1605 {
1606
4/4
✓ Branch 0 taken 1222537 times.
✓ Branch 1 taken 476043 times.
✓ Branch 2 taken 1212530 times.
✓ Branch 3 taken 10007 times.
2911110 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1607
2/2
✓ Branch 0 taken 14572 times.
✓ Branch 1 taken 1197958 times.
1212530 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1608 }
1609 else
1610 {
1611
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 17040 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102594 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1612
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1613
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1614
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1615 }
1616 10078278 }
1617
1618 496901 bool enemy::isOnSideviewPlatform()
1619 {
1620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1622
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1623 return false;
1624
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1626
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1627 {
1628
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1629
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1631 64328 }
1632 215641 return false;
1633 496901 }
1634
1635 // Stops playing the given sound only if there are no enemies left to play it
1636 765984 void enemy::stop_bgsfx(int32_t index)
1637 {
1638
2/2
✓ Branch 0 taken 750904 times.
✓ Branch 1 taken 15080 times.
765984 if(bgsfx<=0)
1639 750904 return;
1640
1641 // Look for other enemies with the same bgsfx
1642
2/2
✓ Branch 0 taken 52960 times.
✓ Branch 1 taken 8776 times.
61736 for(int32_t i=0; i<guys.Count(); i++)
1643 {
1644
4/4
✓ Branch 0 taken 41898 times.
✓ Branch 1 taken 11062 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35594 times.
52960 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1645 6304 return;
1646 46656 }
1647
1648 8776 stop_sfx(bgsfx);
1649 765984 }
1650
1651
1652 // to allow for different sfx on defeating enemy
1653 40189 void enemy::death_sfx()
1654 {
1655
2/2
✓ Branch 0 taken 39904 times.
✓ Branch 1 taken 285 times.
40189 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1656 40189 }
1657
1658 void enemy::move(zfix dx,zfix dy)
1659 {
1660 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1661 {
1662 x+=dx;
1663 y+=dy;
1664 }
1665 }
1666
1667 18283760 void enemy::move(zfix s)
1668 {
1669
9/10
✓ Branch 0 taken 18283721 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18174612 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18283760 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1670 {
1671 18282716 sprite::move(s);
1672 18282716 }
1673 18283760 }
1674
1675 43669 void enemy::leave_item()
1676 {
1677 43669 int32_t drop_item = select_dropitem(item_set, x, y);
1678 43669 int32_t thedropset = item_set;
1679
1680 43669 std::vector<int32_t> &ev = FFCore.eventData;
1681 43669 ev.clear();
1682 43669 ev.push_back(getUID());
1683 43669 ev.push_back(drop_item*10000);
1684 43669 ev.push_back(thedropset*10000);
1685
1686 43669 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1687 43669 drop_item = vbound(ev[1] / 10000,-2,255);
1688 43669 thedropset = ev[2] / 10000;
1689 43669 ev.clear();
1690
1/2
✓ Branch 0 taken 43669 times.
✗ Branch 1 not taken.
43669 if(drop_item == -2)
1691 {
1692 drop_item = select_dropitem(thedropset,x,y);
1693 }
1694
1695
6/6
✓ Branch 0 taken 16477 times.
✓ Branch 1 taken 27192 times.
✓ Branch 2 taken 916 times.
✓ Branch 3 taken 15561 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 747 times.
43669 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1696 {
1697 item* itm;
1698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16308 times.
16308 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1699 {
1700 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1701 }
1702 else
1703 {
1704
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14588 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16308 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1705
4/8
✓ Branch 0 taken 14588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14588 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14588 times.
✗ Branch 7 not taken.
14588 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1706 }
1707 16308 itm->from_dropset = thedropset;
1708 16308 add_item_for_screen(screen_spawned, itm);
1709
1710 16308 ev.push_back(getUID());
1711 16308 ev.push_back(itm->getUID());
1712
1713 16308 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1714 16308 ev.clear();
1715 16308 }
1716 43669 }
1717
1718 // auomatically kill off enemy (for rooms with ringleaders)
1719 411 void enemy::kickbucket()
1720 {
1721
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
411 if(!superman && !(flags&guy_ignore_kill_all))
1722 379 hp=-1000; // don't call death_sfx()
1723 411 }
1724
1725 21250 bool enemy::isSubmerged() const
1726 {
1727 21250 return submerged;
1728 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1729 }
1730
1731 20895 void enemy::FireBreath(bool seekhero)
1732 {
1733
1/2
✓ Branch 0 taken 20895 times.
✗ Branch 1 not taken.
20895 if(wpn==wNone)
1734 return;
1735
1736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20895 times.
20895 if(wpn==ewFireTrail)
1737 {
1738 dmisc1 = e1tEACHTILE;
1739 FireWeapon();
1740 return;
1741 }
1742
1743 20895 float fire_angle=0.0;
1744 20895 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1745
1746
1/2
✓ Branch 0 taken 20895 times.
✗ Branch 1 not taken.
20895 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1747 {
1748 xoff += hxofs;
1749 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1750 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1751 else
1752 xoff += (hit_width / 2) - 8;
1753 }
1754
1/2
✓ Branch 0 taken 20895 times.
✗ Branch 1 not taken.
20895 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1755 {
1756 yoff += hyofs;
1757 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1758 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1759 else
1760 yoff += (hit_height / 2) - 8;
1761 }
1762
1763
2/2
✓ Branch 0 taken 5024 times.
✓ Branch 1 taken 15871 times.
20895 if(!seekhero)
1764 {
1765
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1766 {
1767 case down:
1768 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1769 3079 wx=x;
1770 3079 wy=y+8;
1771 3079 break;
1772
1773 case -1:
1774 case up:
1775 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1776 3297 wx=x;
1777 3297 wy=y-8;
1778 3297 break;
1779
1780 case left:
1781 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1782 5287 wx=x-8;
1783 5287 wy=y;
1784 5287 break;
1785
1786 case right:
1787 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1788 4208 wx=x+8;
1789 4208 wy=y;
1790 4208 break;
1791 }
1792
1793
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1794 {
1795
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1801
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1802
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1803 15735 }
1804 15871 }
1805 else
1806 {
1807 5024 wx = x;
1808 5024 wy = y;
1809 }
1810
1811
2/2
✓ Branch 0 taken 5024 times.
✓ Branch 1 taken 15871 times.
20895 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1812 20895 sfx(wpnsfx(wpn),pan(int32_t(x)));
1813
1814 20895 int32_t i=Ewpns.Count()-1;
1815 20895 weapon *ew = (weapon*)(Ewpns.spr(i));
1816 20895 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1817
1818
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5024 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20895 if(!seekhero && (zc_oldrand()&4))
1819 {
1820 7957 ew->angular=true;
1821 7957 ew->angle=fire_angle;
1822 7957 }
1823
1824
4/4
✓ Branch 0 taken 20619 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20302 times.
20895 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1825 {
1826 20302 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20302 times.
20302 if ( ew->do_animation ) ew->tile+=ew->aframe;
1828 20302 }
1829
1830
2/2
✓ Branch 0 taken 20895 times.
✓ Branch 1 taken 765882 times.
786777 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1831 {
1832 765882 Ewpns.swap(j,j-1);
1833 765882 }
1834 20895 }
1835
1836 44304 void enemy::FireWeapon()
1837 {
1838 /*
1839 * Type:
1840 * 0x01: Boss fireball
1841 * 0x02: Seeks Hero
1842 * 0x04: Fast projectile
1843 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1844 */
1845
1846
2/2
✓ Branch 0 taken 44173 times.
✓ Branch 1 taken 131 times.
44304 if (wpn < 1) return;
1847
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44173 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44173 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1848 return;
1849
1850
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44173 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44173 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1851 dmisc1 = e1tEACHTILE;
1852
1853 44173 int32_t xoff = 0;
1854 44173 int32_t yoff = 0;
1855
1/2
✓ Branch 0 taken 44173 times.
✗ Branch 1 not taken.
44173 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1856 {
1857 xoff += hxofs;
1858 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1859 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1860 else
1861 xoff += (hit_width / 2) - 8;
1862 }
1863
1/2
✓ Branch 0 taken 44173 times.
✗ Branch 1 not taken.
44173 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1864 {
1865 yoff += hyofs;
1866 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1867 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1868 else
1869 yoff += (hit_height / 2) - 8;
1870 }
1871
1872 // TODO(crash): check that .add succeeds.
1873
1874
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41237 times.
✓ Branch 2 taken 1776 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44173 switch(dmisc1)
1875 {
1876 case e1t5SHOTS: //BS-Aquamentus
1877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1879 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1880 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1881
1882 [[fallthrough]];
1883 case e1t3SHOTSFAST:
1884 case e1t3SHOTS: //Aquamentus
1885
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1886 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1887
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1888 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1889
1890 [[fallthrough]];
1891 default:
1892
12/20
✓ Branch 0 taken 41883 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41883 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41883 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41883 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 41883 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 41878 times.
✓ Branch 12 taken 41883 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18040 times.
✓ Branch 15 taken 23843 times.
✓ Branch 16 taken 41883 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 41883 times.
✗ Branch 19 not taken.
41883 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1893 41883 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1894 41883 sfx(wpnsfx(wpn),pan(int32_t(x)));
1895 41883 break;
1896
1897 case e1tSLANT:
1898 {
1899 416 int32_t slant = 0;
1900
1901
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1902 246 slant = left;
1903
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1904 117 slant = right;
1905
1906
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1907 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1908 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1909 330 break;
1910 }
1911
1912 case e1t8SHOTS: //Fire Wizzrobe
1913
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1916
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1918 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1919
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1922
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1923 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1924 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1925
1926 [[fallthrough]];
1927 case e1t4SHOTS: //Stalfos 3
1928
7/14
✓ Branch 0 taken 1874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1874 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1874 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1874 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1874 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1874 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1874 times.
✗ Branch 13 not taken.
1874 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1929 1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1930 1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1931
7/14
✓ Branch 0 taken 1874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1874 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1874 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1874 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1874 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1874 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1874 times.
✗ Branch 13 not taken.
1874 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1932 1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1933 1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1934
7/14
✓ Branch 0 taken 1874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1874 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1874 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1874 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1874 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1874 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1874 times.
✗ Branch 13 not taken.
1874 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1935 1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1937
7/14
✓ Branch 0 taken 1874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1874 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1874 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1874 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1874 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1874 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1874 times.
✗ Branch 13 not taken.
1874 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1938 1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1939 1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1940 1874 sfx(wpnsfx(wpn),pan(int32_t(x)));
1941 1874 break;
1942
1943 case e1tSUMMON: // Bat Wizzrobe
1944 {
1945 if(dmisc4==0) break; // Summon 0
1946
1947 int32_t bc=0;
1948
1949 for(int32_t gc=0; gc<guys.Count(); gc++)
1950 {
1951 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1952 {
1953 ++bc;
1954 }
1955 }
1956
1957 if(bc<=40) // Not too many enemies
1958 {
1959 int32_t kids = guys.Count();
1960 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1961
1962 for(int32_t i=0; i<bats; i++)
1963 {
1964 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1965 {
1966 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1967 }
1968 }
1969
1970 sfx(firesfx, pan(int32_t(x)));
1971 }
1972
1973 break;
1974 }
1975
1976 case e1tSUMMONLAYER: // Summoner
1977 {
1978 if(count_layer_enemies(screen_spawned)==0)
1979 {
1980 break;
1981 }
1982
1983 int32_t kids = guys.Count();
1984
1985 if(kids<40)
1986 {
1987 int32_t newguys=(zc_oldrand()%3)+1;
1988 bool summoned=false;
1989
1990 for(int32_t i=0; i<newguys; i++)
1991 {
1992 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1993 int32_t x2=0;
1994 int32_t y2=0;
1995
1996 for(int32_t k=0; k<20; ++k)
1997 {
1998 x2=16*((zc_oldrand()%12)+2);
1999 y2=16*((zc_oldrand()%7)+2);
2000
2001 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2002 {
2003 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2004 {
2005 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2006 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2007 {
2008 ((enemy*)guys.spr(kids+i))->fakez = 64;
2009 ((enemy*)guys.spr(kids+i))->z = 0;
2010 }
2011 }
2012
2013 summoned=true;
2014 break;
2015 }
2016 }
2017 }
2018
2019 if(summoned)
2020 {
2021 sfx(firesfx, pan(int32_t(x)));
2022 }
2023 }
2024
2025 break;
2026 }
2027 }
2028 44218 }
2029
2030
2031 // Hit the shield(s)?
2032 // Apparently, this function is only used for hookshots...
2033 2699 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2034 {
2035
6/6
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 1736 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 821 times.
2699 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2036 821 return false;
2037
2038 1878 bool ret = false;
2039
2040 // TODO: There must be some bitwise operations that can simplify this...
2041
9/12
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 666 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 682 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 682 times.
✓ Branch 10 taken 682 times.
✗ Branch 11 not taken.
1878 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2042
9/12
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 790 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 790 times.
✓ Branch 10 taken 790 times.
✗ Branch 11 not taken.
1169 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2043
2044
11/14
✓ Branch 0 taken 1041 times.
✓ Branch 1 taken 837 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 818 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 794 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 809 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 809 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 809 times.
1878 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2045
11/14
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 855 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 842 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 807 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 824 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 824 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 824 times.
1041 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2046
2047 1878 return ret;
2048 2699 }
2049
2050
2051 //! Weapon Editor for 2.6
2052 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2053
2054
2055 //converts a wqeapon ID to its defence index.
2056 126967 int32_t weaponToDefence(int32_t wid)
2057 {
2058
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64407 times.
✓ Branch 2 taken 9415 times.
✓ Branch 3 taken 25035 times.
✓ Branch 4 taken 4195 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 487 times.
✓ Branch 17 taken 1458 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2699 times.
✓ Branch 21 taken 590 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
126967 switch(wid)
2059 {
2060 case wNone: return -1;
2061 64407 case wSword: return edefSWORD;
2062 9415 case wBeam: return edefBEAM;
2063 25035 case wBrang: return edefBRANG;
2064 4195 case wBomb: return edefBOMB;
2065 37 case wSBomb: return edefSBOMB;
2066 48 case wLitBomb: return edefBOMB;
2067 case wLitSBomb: return edefSBOMB;
2068 3160 case wArrow: return edefARROW;
2069 9836 case wFire: return edefFIRE;
2070 case wWhistle:
2071 {
2072 return edefWhistle;
2073 }
2074 case wBait: return edefBAIT;
2075 269 case wWand: return edefWAND;
2076 1438 case wMagic: return edefMAGIC;
2077 case wCatching: return -1;
2078 case wWind: return edefWIND;
2079 487 case wRefMagic: return edefREFMAGIC;
2080 1458 case wRefFireball: return edefREFBALL;
2081 case wRefRock: return edefREFROCK;
2082 2054 case wHammer: return edefHAMMER;
2083 2699 case wHookshot: return edefHOOKSHOT;
2084 590 case wHSHandle: return edefHOOKSHOT;
2085 case wHSChain: return edefHOOKSHOT;
2086 240 case wSSparkle: return edefSPARKLE;
2087 469 case wFSparkle: return edefSPARKLE;
2088 case wSmack: return -1; // is this the candle object?
2089 case wPhantom: return -1; //engine created visual effects.
2090 case wCByrna: return edefBYRNA;
2091 19 case wRefBeam: return edefREFBEAM;
2092 case wStomp: return edefSTOMP;
2093 28 case wScript1: return edefSCRIPT01;
2094 case wScript2: return edefSCRIPT02;
2095 12 case wScript3: return edefSCRIPT03;
2096 77 case wScript4: return edefSCRIPT04;
2097 case wScript5: return edefSCRIPT05;
2098 case wScript6: return edefSCRIPT06;
2099 case wScript7: return edefSCRIPT07;
2100 case wScript8: return edefSCRIPT08;
2101 case wScript9: return edefSCRIPT09;
2102 993 case wScript10: return edefSCRIPT10;
2103 case wIce: return edefICE;
2104 case wSound: return edefSONIC;
2105 1 case wThrown: return edefTHROWN;
2106 case wRefArrow: return edefREFARROW;
2107 case wRefFire: return edefREFFIRE;
2108 case wRefFire2: return edefREFFIRE2;
2109 //case wPot: return edefPOT;
2110 // case wLitZap: return edefELECTRIC;
2111 // case wZ3Sword: return edefZ3SWORD;
2112 // case wLASWord: return edefLASWORD;
2113 // case wSpinAttk: return edefSPINATTK;
2114 // case wShield: return edefSHIELD;
2115 // case wTrowel: return edefTROWEL;
2116
2117 default: return -1;
2118 }
2119 126967 }
2120
2121 126967 int32_t getDefType(weapon *w)
2122 {
2123 126967 int32_t id = getWeaponID(w);
2124 126967 int32_t edef = weaponToDefence(id);
2125
2/2
✓ Branch 0 taken 123678 times.
✓ Branch 1 taken 3289 times.
126967 if(edef == edefHOOKSHOT)
2126 {
2127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3289 times.
3289 if(w->family_class == itype_switchhook)
2128 return edefSwitchHook;
2129 3289 }
2130 126967 return edef;
2131 126967 }
2132
2133 226200 int32_t getWeaponID(weapon *w)
2134 {
2135 226200 int32_t usewpn = w->useweapon;
2136
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 225970 times.
226200 return (usewpn > 0) ? usewpn : w->id;
2137 }
2138
2139 126967 int32_t enemy::resolveEnemyDefence(weapon *w)
2140 {
2141 //sword edef is 9, but we're reading it at 0
2142 //,
2143 126967 int32_t weapondef = 0;
2144 126967 int32_t wdeftype = getDefType(w);
2145 126967 int32_t usedef = w->usedefense;
2146
2147
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126967 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
126967 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2148 {
2149 weapondef = usedef*-1;
2150 }
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126967 times.
126967 else if(unsigned(wdeftype) < edefLAST255)
2152 {
2153 126967 weapondef = wdeftype;
2154 126967 }
2155 126967 return weapondef;
2156 }
2157
2158 137391 byte get_def_ignrflag(int32_t edef)
2159 {
2160
3/3
✓ Branch 0 taken 114469 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19239 times.
137391 switch(edef)
2161 {
2162 case edIGNORE:
2163 case edIGNOREL1:
2164 case edSTUNORIGNORE:
2165 19239 return WPNUNB_IGNR;
2166 case edSTUNORCHINK:
2167 case edCHINK:
2168 case edCHINKL1:
2169 case edCHINKL2:
2170 case edCHINKL4:
2171 case edCHINKL6:
2172 case edCHINKL8:
2173 case edCHINKL10:
2174 case edLEVELCHINK2:
2175 case edLEVELCHINK3:
2176 case edLEVELCHINK4:
2177 case edLEVELCHINK5:
2178 3683 return WPNUNB_BLOCK;
2179 }
2180 114469 return 0;
2181 137391 }
2182
2183 137391 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2184 {
2185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137391 times.
137391 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2186 switch(edef)
2187 {
2188 case edIGNORE:
2189 case edIGNOREL1:
2190 case edCHINK:
2191 case edCHINKL1:
2192 case edCHINKL2:
2193 case edCHINKL4:
2194 case edCHINKL6:
2195 case edCHINKL8:
2196 case edCHINKL10:
2197 case edLEVELCHINK2:
2198 case edLEVELCHINK3:
2199 case edLEVELCHINK4:
2200 case edLEVELCHINK5:
2201 return edNORMAL;
2202 case edSTUNORIGNORE:
2203 case edSTUNORCHINK:
2204 return edSTUNONLY;
2205 }
2206 return edef;
2207 137391 }
2208
2209 // Do we do damage?
2210 // 0: takehit returns 0
2211 // 1: takehit returns 1
2212 // -1: do damage
2213 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2214 125974 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2215 {
2216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125974 times.
125974 if(switch_hooked) return 0;
2217 125974 int32_t tempx = x;
2218 125974 int32_t tempy = y;
2219 125974 int32_t the_defence = 0;
2220
1/2
✓ Branch 0 taken 125974 times.
✗ Branch 1 not taken.
125974 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2221 {
2222 the_defence = edef*-1; //A specific defence type.
2223 }
2224 125974 else the_defence = defense[edef];
2225
2226 125974 the_defence = conv_edef_unblockable(the_defence, unblockable);
2227
2228
3/4
✓ Branch 0 taken 6581 times.
✓ Branch 1 taken 119393 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6581 times.
125974 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2229 {
2230
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6574 times.
✓ Branch 2 taken 7 times.
6581 switch(the_defence)
2231 {
2232 case edIGNORE:
2233 7 return 0;
2234 case edIGNOREL1:
2235 case edSTUNORIGNORE:
2236 if(*power <= 0)
2237 return 0;
2238 }
2239 6574 sfx(WAV_CHINK,pan(int32_t(x)));
2240 6574 return 1;
2241 }
2242
2243 119393 int32_t new_id = id;
2244 119393 int32_t effect_type = dmisc15;
2245 119393 int32_t delay_timer = 90;
2246 119393 enemy *gleeok = NULL;
2247 119393 enemy *ptra = NULL;
2248 119393 int32_t c = 0;
2249
2250
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1829 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17301 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93213 times.
119393 switch(the_defence)
2251 {
2252 case edREPLACE:
2253 {
2254 sclk = 0;
2255 if ( dmisc16 > 0 ) new_id = dmisc16;
2256 else new_id = id+1;
2257 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2258 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2259 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2260
2261 //Z_scripterrlog("new id is %d\n", new_id);
2262 switch(guysbuf[new_id&0xFFF].family)
2263 {
2264 //Fixme: possible enemy memory leak. (minor)
2265 case eeWALK:
2266 {
2267 enemy *e = new eStalfos(x,y,new_id,clk);
2268 guys.add(e);
2269 }
2270 break;
2271
2272 case eeLEV:
2273 {
2274 enemy *e = new eLeever(x,y,new_id,clk);
2275 guys.add(e);
2276 }
2277 break;
2278
2279 case eeTEK:
2280 {
2281 enemy *e = new eTektite(x,y,new_id,clk);
2282 guys.add(e);
2283 }
2284 break;
2285
2286 case eePEAHAT:
2287 {
2288 enemy *e = new ePeahat(x,y,new_id,clk);
2289 guys.add(e);
2290 }
2291 break;
2292
2293 case eeZORA:
2294 {
2295 enemy *e = new eZora(x,y,new_id,clk);
2296 guys.add(e);
2297 }
2298 break;
2299
2300 case eeGHINI:
2301 {
2302 enemy *e = new eGhini(x,y,new_id,clk);
2303 guys.add(e);
2304 }
2305 break;
2306
2307 case eeKEESE:
2308 {
2309 enemy *e = new eKeese(x,y,new_id,clk);
2310 guys.add(e);
2311 }
2312 break;
2313
2314 case eeWIZZ:
2315 {
2316 enemy *e = new eWizzrobe(x,y,new_id,clk);
2317 guys.add(e);
2318 }
2319 break;
2320
2321 case eePROJECTILE:
2322 {
2323 enemy *e = new eProjectile(x,y,new_id,clk);
2324 guys.add(e);
2325 }
2326 break;
2327
2328 case eeWALLM:
2329 {
2330 enemy *e = new eWallM(x,y,new_id,clk);
2331 guys.add(e);
2332 }
2333 break;
2334
2335 case eeAQUA:
2336 {
2337 enemy *e = new eAquamentus(x,y,new_id,clk);
2338 guys.add(e);
2339 e->x = x;
2340 e->y = y;
2341 }
2342 break;
2343
2344 case eeMOLD:
2345 {
2346 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2347 guys.add(e);
2348 e->x = x;
2349 e->y = y;
2350 }
2351 break;
2352
2353 case eeMANHAN:
2354 {
2355 enemy *e = new eManhandla(x,y,new_id,clk);
2356 guys.add(e);
2357 e->x = x;
2358 e->y = y;
2359 }
2360 break;
2361
2362 case eeGLEEOK:
2363 {
2364 *power = 0;
2365 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2366 guys.add(gleeok);
2367 // TODO(crash): check that .add succeeds.
2368 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2369 new_id &= 0xFFF;
2370 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2371 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2372 for(int32_t i=0; i<head_cnt; i++)
2373 {
2374 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2375 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2376 {
2377 al_trace("Gleeok head %d could not be created!\n",i+1);
2378
2379 for(int32_t j=0; j<i+1; j++)
2380 {
2381 guys.del(guys.Count()-1);
2382 }
2383
2384 break;
2385 }
2386 else
2387 {
2388 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2389 }
2390
2391 c-=guysbuf[new_id].attributes[3];
2392 }
2393 return 1;
2394 }
2395
2396 case eeGHOMA:
2397 {
2398 enemy *e = new eGohma(x,y,new_id,clk);
2399 guys.add(e);
2400 e->x = x;
2401 e->y = y;
2402 }
2403 break;
2404
2405 case eeLANM:
2406 {
2407 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2408 guys.add(e);
2409 e->x = x;
2410 e->y = y;
2411 }
2412 break;
2413
2414 case eeGANON:
2415 {
2416 enemy *e = new eGanon(x,y,new_id,clk);
2417 guys.add(e);
2418 e->x = x;
2419 e->y = y;
2420 }
2421 break;
2422
2423 case eeFAIRY:
2424 {
2425 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2426 guys.add(e);
2427 e->x = x;
2428 e->y = y;
2429 }
2430 break;
2431
2432 case eeFIRE:
2433 {
2434 enemy *e = new eFire(x,y,new_id,clk);
2435 guys.add(e);
2436 e->x = x;
2437 e->y = y;
2438 }
2439 break;
2440
2441 case eeOTHER:
2442 {
2443 enemy *e = new eOther(x,y,new_id,clk);
2444 guys.add(e);
2445 e->x = x;
2446 e->y = y;
2447 }
2448 break;
2449
2450 case eeSPINTILE:
2451 {
2452 enemy *e = new eSpinTile(x,y,new_id,clk);
2453 guys.add(e);
2454 e->x = x;
2455 e->y = y;
2456 }
2457 break;
2458
2459 // and these enemies use the misc10/misc2 value
2460 case eeROCK:
2461 {
2462 switch(guysbuf[new_id&0xFFF].attributes[9])
2463 {
2464 case 1:
2465 {
2466 enemy *e = new eBoulder(x,y,new_id,clk);
2467 guys.add(e);
2468 e->x = x;
2469 e->y = y;
2470 }
2471 break;
2472
2473 case 0:
2474 default:
2475 {
2476 enemy *e = new eRock(x,y,new_id,clk);
2477 guys.add(e);
2478 e->x = x;
2479 e->y = y;
2480 }
2481 break;
2482 }
2483
2484 break;
2485 }
2486
2487 case eeTRAP:
2488 {
2489 switch(guysbuf[new_id&0xFFF].attributes[1])
2490 {
2491 case 1:
2492 {
2493 enemy *e = new eTrap2(x,y,new_id,clk);
2494 guys.add(e);
2495 e->x = x;
2496 e->y = y;
2497 }
2498 break;
2499
2500 case 0:
2501 default:
2502 {
2503 enemy *e = new eTrap(x,y,new_id,clk);
2504 guys.add(e);
2505 e->x = x;
2506 e->y = y;
2507 }
2508 break;
2509 }
2510
2511 break;
2512 }
2513
2514 case eeDONGO:
2515 {
2516 switch(guysbuf[new_id&0xFFF].attributes[9])
2517 {
2518 case 1:
2519 {
2520 enemy *e = new eDodongo2(x,y,new_id,clk);
2521 guys.add(e);
2522 e->x = x;
2523 e->y = y;
2524 }
2525 break;
2526
2527 case 0:
2528 default:
2529 {
2530 enemy *e = new eDodongo(x,y,new_id,clk);
2531 guys.add(e);
2532 e->x = x;
2533 e->y = y;
2534 }
2535 break;
2536 }
2537
2538 break;
2539 }
2540
2541 case eeDIG:
2542 {
2543 switch(guysbuf[new_id&0xFFF].attributes[9])
2544 {
2545 case 1:
2546 {
2547 enemy *e = new eLilDig(x,y,new_id,clk);
2548 guys.add(e);
2549 e->x = x;
2550 e->y = y;
2551 }
2552 break;
2553
2554 case 0:
2555 default:
2556 {
2557 enemy *e = new eBigDig(x,y,new_id,clk);
2558 guys.add(e);
2559 e->x = x;
2560 e->y = y;
2561 }
2562 break;
2563 }
2564
2565 break;
2566 }
2567
2568 case eePATRA:
2569 {
2570 switch(guysbuf[new_id&0xFFF].attributes[9])
2571 {
2572 case 1:
2573 {
2574 if (get_qr(qr_HARDCODED_BS_PATRA))
2575 {
2576 enemy *e = new ePatraBS(x,y,new_id,clk);
2577 guys.add(e);
2578 e->x = x;
2579 e->y = y;
2580 break;
2581 }
2582 }
2583 [[fallthrough]];
2584 case 0:
2585 default:
2586 {
2587 enemy *e = new ePatra(x,y,new_id,clk);
2588 guys.add(e);
2589 e->x = x;
2590 e->y = y;
2591 }
2592 break;
2593 }
2594
2595 break;
2596 }
2597
2598 case eeGUY:
2599 {
2600 switch(guysbuf[new_id&0xFFF].attributes[9])
2601 {
2602 case 1:
2603 {
2604 enemy *e = new eTrigger(x,y,new_id,clk);
2605 guys.add(e);
2606 }
2607 break;
2608
2609 case 0:
2610 default:
2611 {
2612 enemy *e = new eNPC(x,y,new_id,clk);
2613 guys.add(e);
2614 }
2615 break;
2616 }
2617
2618 break;
2619 }
2620
2621 case eeSCRIPT01:
2622 case eeSCRIPT02:
2623 case eeSCRIPT03:
2624 case eeSCRIPT04:
2625 case eeSCRIPT05:
2626 case eeSCRIPT06:
2627 case eeSCRIPT07:
2628 case eeSCRIPT08:
2629 case eeSCRIPT09:
2630 case eeSCRIPT10:
2631 case eeSCRIPT11:
2632 case eeSCRIPT12:
2633 case eeSCRIPT13:
2634 case eeSCRIPT14:
2635 case eeSCRIPT15:
2636 case eeSCRIPT16:
2637 case eeSCRIPT17:
2638 case eeSCRIPT18:
2639 case eeSCRIPT19:
2640 case eeSCRIPT20:
2641 {
2642 enemy *e = new eScript(x,y,new_id,clk);
2643 guys.add(e);
2644 e->x = x;
2645 e->y = y;
2646 break;
2647 }
2648
2649
2650 case eeFFRIENDLY01:
2651 case eeFFRIENDLY02:
2652 case eeFFRIENDLY03:
2653 case eeFFRIENDLY04:
2654 case eeFFRIENDLY05:
2655 case eeFFRIENDLY06:
2656 case eeFFRIENDLY07:
2657 case eeFFRIENDLY08:
2658 case eeFFRIENDLY09:
2659 case eeFFRIENDLY10:
2660 {
2661 enemy *e = new eFriendly(x,y,new_id,clk);
2662 guys.add(e);
2663 e->x = x;
2664 e->y = y;
2665 break;
2666 }
2667
2668
2669 default: break;
2670 }
2671
2672 // add segments of segmented enemies
2673 int32_t c=0;
2674
2675 switch(guysbuf[new_id&0xFFF].family)
2676 {
2677 case eeMOLD:
2678 {
2679 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2680 new_id &= 0xFFF;
2681
2682 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2683 {
2684 //christ this is messy -DD
2685 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2686
2687 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2688 {
2689 al_trace("Moldorm segment %d could not be created!\n",i+1);
2690
2691 for(int32_t j=0; j<i+1; j++)
2692 guys.del(guys.Count()-1);
2693
2694 return 0;
2695 }
2696
2697 if(i>0)
2698 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2699
2700
2701 }
2702
2703 break;
2704 }
2705
2706 case eeLANM:
2707 {
2708 new_id &= 0xFFF;
2709 int32_t shft = guysbuf[new_id].attributes[1];
2710 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2711 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2712
2713 if(!guys.add(e))
2714 {
2715 al_trace("Lanmola segment 1 could not be created!\n");
2716 guys.del(guys.Count()-1);
2717 return 0;
2718 }
2719 e->x = x;
2720 e->y = y;
2721
2722
2723
2724 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2725 {
2726 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2727 if(!guys.add(e2))
2728 {
2729 al_trace("Lanmola segment %d could not be created!\n",i+1);
2730
2731 for(int32_t j=0; j<i+1; j++)
2732 guys.del(guys.Count()-1);
2733
2734 return 0;
2735 }
2736 e2->x = x;
2737 e2->y = y;
2738
2739 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2740
2741 }
2742 }
2743 break;
2744
2745 case eeMANHAN:
2746 new_id &= 0xFFF;
2747
2748 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2749 {
2750 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2751 {
2752 al_trace("Manhandla head %d could not be created!\n",i+1);
2753
2754 for(int32_t j=0; j<i+1; j++)
2755 {
2756 guys.del(guys.Count()-1);
2757 }
2758
2759 return 0;
2760 }
2761
2762
2763 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2764 }
2765
2766 break;
2767
2768 case eeGLEEOK:
2769 {
2770 /*
2771 new_id &= 0xFFF;
2772 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2773 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2774 for(int32_t i=0; i<head_cnt; i++)
2775 {
2776 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2777 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2778 {
2779 al_trace("Gleeok head %d could not be created!\n",i+1);
2780
2781 for(int32_t j=0; j<i+1; j++)
2782 {
2783 guys.del(guys.Count()-1);
2784 }
2785
2786 break;
2787 }
2788
2789 c-=guysbuf[new_id].misc4;
2790 */
2791
2792 // }
2793 }
2794 break;
2795
2796
2797 case eePATRA:
2798 {
2799 new_id &= 0xFFF;
2800 int32_t outeyes = 0;
2801 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2802
2803 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2804 {
2805 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2806 {
2807 al_trace("Patra outer eye %d could not be created!\n",i+1);
2808
2809 for(int32_t j=0; j<i+1; j++)
2810 guys.del(guys.Count()-1);
2811
2812 return 0;
2813 }
2814 else
2815 outeyes++;
2816
2817
2818 }
2819
2820 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2821 {
2822 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2823 {
2824 al_trace("Patra inner eye %d could not be created!\n",i+1);
2825
2826 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2827 guys.del(guys.Count()-1);
2828
2829 return 0;
2830 }
2831
2832
2833 }
2834 delete ptra;
2835 break;
2836 }
2837 }
2838
2839
2840 // TODO(crash): check that the above .add succeeded.
2841 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2842 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2843 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2844 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2845 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2846 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2847 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2848 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2849 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2850 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2851 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2852 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2853
2854
2855 item_set = 0; //Do not make a drop.
2856
2857 switch(effect_type)
2858 {
2859 case -7:
2860 {
2861 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2862 Lwpns.add(w);
2863 break;
2864 }
2865 case -6:
2866 {
2867 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2868 Lwpns.add(w);
2869 break;
2870 }
2871 case -5:
2872 {
2873 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2874 Lwpns.add(w);
2875 break;
2876 }
2877 case -4:
2878 {
2879 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2880 Lwpns.add(w);
2881 break;
2882 }
2883 case -3: explode(1); break;
2884 case -2: explode(2); break;
2885 case -1: explode(0); break;
2886 case 0: break;
2887
2888 default:
2889 {
2890 //Dummy weapon function
2891 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2892 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2893 Lwpns.add(w);
2894 break;
2895 }
2896 }
2897
2898
2899 yofs = -32768;
2900 switch(guysbuf[new_id&0xFFF].family)
2901 {
2902 case eeGLEEOK:
2903 {
2904 Z_scripterrlog("Replacing a gleeok.\n");
2905 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2906 hp = -999;
2907 if (tempenemy) tempenemy->hp = -999;
2908 break;
2909
2910 }
2911 default:
2912 hp = -1000; break;
2913 }
2914 int mi = mapind(cur_map, screen_spawned);
2915 ++game->guys[mi];
2916 return 1;
2917
2918 }
2919 case edSPLIT:
2920 {
2921 for ( int32_t q = 0; q < dmisc4; q++ )
2922 {
2923 addenemy(screen_spawned,x,y,
2924 dmisc3+0x1000,-15);
2925
2926 }
2927 item_set = 0; //Do not make a drop.
2928 hp = -1000;
2929 return -1;
2930
2931 }
2932 case edSUMMON:
2933 {
2934 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2935 for ( int32_t q = 0; q < summon_count; q++ )
2936 {
2937 int32_t x2=16*((zc_oldrand()%12)+2);
2938 int32_t y2=16*((zc_oldrand()%7)+2);
2939 addenemy(screen_spawned,
2940 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2941 x2,y2,
2942 dmisc3+0x1000,-15);
2943
2944 }
2945 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2946 return -1;
2947
2948 }
2949
2950 case edEXPLODESMALL:
2951 {
2952 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2953 Ewpns.add(ew);
2954 item_set = 0; //Should we make a drop?
2955 hp = -1000;
2956 return -1;
2957 }
2958
2959
2960 case edEXPLODEHARMLESS:
2961 {
2962 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2963 Ewpns.add(ew);
2964 ew->hyofs = -32768;
2965 item_set = 0; //Should we make a drop?
2966 hp = -1000;
2967 return -1;
2968 }
2969
2970
2971 case edEXPLODELARGE:
2972 {
2973 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2974 Ewpns.add(ew);
2975
2976 hp = -1000;
2977 return -1;
2978 }
2979
2980
2981 case edTRIGGERSECRETS:
2982 {
2983 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2984 return -1;
2985 }
2986
2987 case edSTUNORCHINK:
2988
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2989 {
2990 649 sfx(WAV_CHINK,pan(int32_t(x)));
2991 649 return 1;
2992 }
2993
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2994 {
2995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2996 return 0;
2997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2998 {
2999 sfx(WAV_CHINK,pan(int32_t(x)));
3000 return 1;
3001 }
3002 1119 }
3003 [[fallthrough]];
3004
3005 case edSTUNORIGNORE:
3006
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 if(*power <= 0)
3007 955 return 0;
3008
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3009 {
3010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3011 return 0;
3012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3013 {
3014 sfx(WAV_CHINK,pan(int32_t(x)));
3015 return 1;
3016 }
3017 1952 }
3018 [[fallthrough]];
3019
3020 case edSTUNONLY:
3021
7/10
✓ Branch 0 taken 4331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4331 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3797 times.
✓ Branch 7 taken 534 times.
✓ Branch 8 taken 4019 times.
✓ Branch 9 taken 312 times.
4331 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3022 {
3023 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3024 312 return 1;
3025 }
3026
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 3102 times.
4019 if (stunclk)
3027 {
3028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3102 times.
3102 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3029 return 0;
3030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3102 times.
3102 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3031 {
3032 sfx(WAV_CHINK,pan(int32_t(x)));
3033 return 1;
3034 }
3035 3102 }
3036 4019 stunclk=160;
3037 4019 sfx(WAV_EHIT,pan(int32_t(x)));
3038 4019 return 1;
3039
3040 case edCHINKL1:
3041 if(*power >= 1*game->get_hero_dmgmult()) break;
3042 [[fallthrough]];
3043 case edCHINKL2:
3044
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3045 [[fallthrough]];
3046 case edCHINKL4:
3047
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3048 [[fallthrough]];
3049 case edCHINKL6:
3050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3051 [[fallthrough]];
3052 case edCHINKL8:
3053
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3054 [[fallthrough]];
3055 case edCHINKL10:
3056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3057 [[fallthrough]];
3058 case edCHINK:
3059 1056 sfx(WAV_CHINK,pan(int32_t(x)));
3060 1056 return 1;
3061
3062 case edIGNOREL1:
3063 if(*power > 0) break;
3064 [[fallthrough]];
3065
3066 case edIGNORE:
3067 17301 return 0;
3068
3069 case ed1HKO:
3070 492 *power = hp;
3071 492 return -3;
3072
3073 case ed2x:
3074 {
3075
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3076 //int32_t pow = *power;
3077 //*power = vbound((pow*2),0,214747);
3078 71 return -1;
3079 }
3080 case ed3x:
3081 {
3082 *power = zc_max(1,*power*3);
3083 //int32_t pow = *power;
3084 //*power = vbound((pow*3),0,214747);
3085 return -1;
3086 }
3087
3088 case ed4x:
3089 {
3090 *power = zc_max(1,*power*4);
3091 //int32_t pow = *power;
3092 //*power = vbound((pow*4),0,214747);
3093 return -1;
3094 }
3095
3096
3097 case edHEAL:
3098 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3099 //int32_t pow = *power;
3100 //*power = vbound((pow*-1),0,214747);
3101 //break;
3102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3103 158 return -1;
3104 }
3105 /*
3106 case edLEVELDAMAGE:
3107 {
3108 int32_t pow = *power;
3109 int32_t lvl = *level;
3110 *power = vbound((pow*lvl),0,214747);
3111 break;
3112 }
3113 case edLEVELREDUCTION:
3114 {
3115 int32_t pow = *power;
3116 int32_t lvl = *level;
3117 *power = vbound((pow/lvl),0,214747);
3118 break;
3119 }
3120 */
3121
3122 case edQUARTDAMAGE:
3123
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3124
3125 [[fallthrough]];
3126 case edHALFDAMAGE:
3127
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3128 988 break;
3129
3130 case edSWITCH:
3131 {
3132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3134 {
3135 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3136 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3137 return 0;
3138 }
3139 4 hooked_comborpos = rpos_t::None;
3140 4 hooked_layerbits = 0;
3141 4 switching_object = this;
3142 4 switch_hooked = true;
3143 4 Hero.doSwitchHook(game->get_switchhookstyle());
3144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3145 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3146 4 return 1;
3147 }
3148
3149 case 0:
3150 {
3151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93213 times.
93213 if(edef == edefSwitchHook)
3152 return -1;
3153
4/4
✓ Branch 0 taken 19490 times.
✓ Branch 1 taken 73723 times.
✓ Branch 2 taken 7725 times.
✓ Branch 3 taken 11765 times.
93213 if (stunclk && *power == 0)
3154 {
3155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11765 times.
11765 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3156 return 0;
3157
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11739 times.
11765 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3158 {
3159 26 sfx(WAV_CHINK,pan(int32_t(x)));
3160 26 return 1;
3161 }
3162 11739 }
3163 93187 break;
3164 }
3165 }
3166
3167 94350 return -1;
3168 125974 }
3169
3170 125974 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3171 {
3172
1/2
✓ Branch 0 taken 125974 times.
✗ Branch 1 not taken.
125974 int wuid = w?w->getUID():0;
3173
1/2
✓ Branch 0 taken 125974 times.
✗ Branch 1 not taken.
125974 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3174
3175
1/2
✓ Branch 0 taken 125974 times.
✗ Branch 1 not taken.
125974 if(fakeweap)
3176 Lwpns.add(w);
3177 125974 std::vector<int32_t> &ev = FFCore.eventData;
3178 125974 ev.clear();
3179 125974 ev.push_back(*power*10000);
3180 125974 ev.push_back(edef*10000);
3181 125974 ev.push_back(unblockable*10000);
3182 125974 ev.push_back(wpnId*10000);
3183 125974 ev.push_back(0);
3184 125974 ev.push_back(getUID());
3185 125974 ev.push_back(wuid);
3186
3187 125974 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3188 125974 *power = ev[0]/10000;
3189 125974 edef = ev[1]/10000;
3190 125974 unblockable = byte(ev[2]/10000);
3191 125974 wpnId = ev[3] / 10000;
3192 125974 bool nullify = ev[4]!=0;
3193 125974 ev.clear();
3194 125974 int ret = 0;
3195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125974 times.
125974 if(!nullify)
3196 {
3197 125974 ret = defendNew(wpnId, power, edef, unblockable);
3198
2/2
✓ Branch 0 taken 32261 times.
✓ Branch 1 taken 93713 times.
125974 if(ret < 0)
3199 {
3200 93713 ev.push_back(*power*10000);
3201 93713 ev.push_back(edef*10000);
3202 93713 ev.push_back(unblockable*10000);
3203 93713 ev.push_back(wpnId*10000);
3204 93713 ev.push_back(0);
3205 93713 ev.push_back(getUID());
3206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93713 times.
93713 ev.push_back(w?w->getUID():0);
3207
3208 93713 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3209 93713 *power = ev[0]/10000;
3210 93713 nullify = ev[4]!=0;
3211 93713 ev.clear();
3212 93713 }
3213 125974 }
3214
1/2
✓ Branch 0 taken 125974 times.
✗ Branch 1 not taken.
125974 if(fakeweap)
3215 Lwpns.remove(w);
3216
3217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125974 times.
125974 return nullify ? 0 : ret;
3218 }
3219
3220 99233 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3221 {
3222
2/2
✓ Branch 0 taken 98656 times.
✓ Branch 1 taken 577 times.
99233 if(!realweap) realweap = w;
3223 99233 int32_t wid = getWeaponID(w);
3224
3225 99233 int32_t edef = resolveEnemyDefence(w);
3226
2/2
✓ Branch 0 taken 6268 times.
✓ Branch 1 taken 92965 times.
99233 if(QHeader.zelda_version > 0x250)
3227 6268 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3228
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 91972 times.
✗ Branch 2 not taken.
92965 switch(wid)
3229 {
3230 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3231 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3232 993 return defend(wpnId, power, edefSCRIPT);
3233
3234 case wWhistle:
3235 return -1;
3236
3237 default:
3238 91972 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3239 }
3240 99233 }
3241
3242
3243 // Check defenses without actually acting on them.
3244 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3245 {
3246
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3247 {
3248 case edSTUNONLY:
3249 474 return false;
3250 case edSTUNORCHINK:
3251 case edCHINK:
3252 15409 return unblockable&WPNUNB_BLOCK;
3253 case edSTUNORIGNORE:
3254 case edIGNORE:
3255 11050 return unblockable&WPNUNB_IGNR;
3256
3257 case edIGNOREL1:
3258 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3259 case edCHINKL1:
3260 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3261
3262 case edCHINKL2:
3263 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3264
3265 case edCHINKL4:
3266 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3267
3268 case edCHINKL6:
3269 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3270
3271 case edCHINKL8:
3272 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3273 }
3274
3275 469 return true;
3276 27402 }
3277
3278 // Do we do damage?
3279 // 0: takehit returns 0
3280 // 1: takehit returns 1
3281 // -1: do damage
3282 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3283 {
3284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3285 {
3286 switch(defense[edef])
3287 {
3288 case edIGNORE:
3289 return 0;
3290 case edIGNOREL1:
3291 case edSTUNORIGNORE:
3292 if(*power <= 0)
3293 return 0;
3294 }
3295
3296 sfx(WAV_CHINK,pan(int32_t(x)));
3297 return 1;
3298 }
3299
3300
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3301 {
3302 case edSTUNORCHINK:
3303 if(*power <= 0)
3304 {
3305 sfx(WAV_CHINK,pan(int32_t(x)));
3306 return 1;
3307 }
3308
3309 [[fallthrough]];
3310 case edSTUNORIGNORE:
3311 if(*power <= 0)
3312 return 0;
3313
3314 [[fallthrough]];
3315 case edSTUNONLY:
3316 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3317 return 1;
3318
3319 stunclk=160;
3320 sfx(WAV_EHIT,pan(int32_t(x)));
3321 return 1;
3322
3323 case edFREEZE:
3324 frozenclock=-1;
3325 //sfx(WAV_FREEZE,pan(int32_t(x)));
3326 return 1;
3327
3328 case edCHINKL1:
3329 if(*power >= 1*game->get_hero_dmgmult()) break;
3330 [[fallthrough]];
3331 case edCHINKL2:
3332 if(*power >= 2*game->get_hero_dmgmult()) break;
3333 [[fallthrough]];
3334 case edCHINKL4:
3335 if(*power >= 4*game->get_hero_dmgmult()) break;
3336 [[fallthrough]];
3337 case edCHINKL6:
3338 if(*power >= 6*game->get_hero_dmgmult()) break;
3339 [[fallthrough]];
3340 case edCHINKL8:
3341 if(*power >= 8*game->get_hero_dmgmult()) break;
3342 [[fallthrough]];
3343 case edCHINKL10:
3344 if(*power >= 10*game->get_hero_dmgmult()) break;
3345 [[fallthrough]];
3346 case edCHINK:
3347 sfx(WAV_CHINK,pan(int32_t(x)));
3348 return 1;
3349 case edTRIGGERSECRETS:
3350 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3351 break;
3352
3353 case edIGNOREL1:
3354 if(*power > 0) break;
3355 [[fallthrough]];
3356 case edIGNORE:
3357 800 return 0;
3358
3359 case ed1HKO:
3360 *power = hp;
3361 return -3;
3362
3363 case ed2x:
3364 {
3365 *power = zc_max(1,*power*2);
3366 //int32_t pow = *power;
3367 //*power = vbound((pow*2),0,214747);
3368 return -1;
3369 }
3370 case ed3x:
3371 {
3372 *power = zc_max(1,*power*3);
3373 //int32_t pow = *power;
3374 //*power = vbound((pow*3),0,214747);
3375 return -1;
3376 }
3377
3378 case ed4x:
3379 {
3380 *power = zc_max(1,*power*4);
3381 //int32_t pow = *power;
3382 //*power = vbound((pow*4),0,214747);
3383 return -1;
3384 }
3385
3386
3387 case edHEAL:
3388 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3389 //int32_t pow = *power;
3390 //*power = vbound((pow*-1),0,214747);
3391 //break;
3392 *power = zc_min(0,*power*-1);
3393 return -1;
3394 }
3395 /*
3396 case edLEVELDAMAGE:
3397 {
3398 int32_t pow = *power;
3399 int32_t lvl = *level;
3400 *power = vbound((pow*lvl),0,214747);
3401 break;
3402 }
3403 case edLEVELREDUCTION:
3404 {
3405 int32_t pow = *power;
3406 int32_t lvl = *level;
3407 *power = vbound((pow/lvl),0,214747);
3408 break;
3409 }
3410 */
3411
3412
3413 case edQUARTDAMAGE:
3414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3415
3416 [[fallthrough]];
3417 case edHALFDAMAGE:
3418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3419 7 break;
3420 }
3421
3422 193 return -1;
3423 993 }
3424
3425 // Defend against a particular item class.
3426 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3427 {
3428 int32_t def=-1;
3429
3430 switch(wpnId)
3431 {
3432 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3433 case wBrang:
3434 def = defend(wpnId, power, edefBRANG);
3435 break;
3436
3437 case wHookshot:
3438 def = defend(wpnId, power, edefHOOKSHOT);
3439 break;
3440
3441 // Anyway...
3442 case wBomb:
3443 def = defend(wpnId, power, edefBOMB);
3444 break;
3445
3446 case wSBomb:
3447 def = defend(wpnId, power, edefSBOMB);
3448 break;
3449
3450 case wArrow:
3451 def = defend(wpnId, power, edefARROW);
3452 break;
3453
3454 case wFire:
3455 def = defend(wpnId, power, edefFIRE);
3456 break;
3457
3458 case wWand:
3459 def = defend(wpnId, power, edefWAND);
3460 break;
3461
3462 case wMagic:
3463 def = defend(wpnId, power, edefMAGIC);
3464 break;
3465
3466 case wHammer:
3467 def = defend(wpnId, power, edefHAMMER);
3468 break;
3469
3470 case wSword:
3471 def = defend(wpnId, power, edefSWORD);
3472 break;
3473
3474 case wBeam:
3475 def = defend(wpnId, power, edefBEAM);
3476 break;
3477
3478 case wRefBeam:
3479 def = defend(wpnId, power, edefREFBEAM);
3480 break;
3481
3482 case wRefMagic:
3483 def = defend(wpnId, power, edefREFMAGIC);
3484 break;
3485
3486 case wRefFireball:
3487 def = defend(wpnId, power, edefREFBALL);
3488 break;
3489
3490 case wRefRock:
3491 def = defend(wpnId, power, edefREFROCK);
3492 break;
3493
3494 case wStomp:
3495 def = defend(wpnId, power, edefSTOMP);
3496 break;
3497
3498 case wCByrna:
3499 def = defend(wpnId, power, edefBYRNA);
3500 break;
3501
3502 case wScript1:
3503 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3504 else def = defend(wpnId, power, edefSCRIPT);
3505 break;
3506
3507 case wScript2:
3508 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3509 else def = defend(wpnId, power, edefSCRIPT);
3510 break;
3511
3512 case wScript3:
3513 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3514 else def = defend(wpnId, power, edefSCRIPT);
3515 break;
3516
3517 case wScript4:
3518 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3519 else def = defend(wpnId, power, edefSCRIPT);
3520 break;
3521
3522 case wScript5:
3523 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3524 else def = defend(wpnId, power, edefSCRIPT);
3525 break;
3526
3527 case wScript6:
3528 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3529 else def = defend(wpnId, power, edefSCRIPT);
3530 break;
3531
3532 case wScript7:
3533 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3534 else def = defend(wpnId, power, edefSCRIPT);
3535 break;
3536
3537 case wScript8:
3538 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3539 else def = defend(wpnId, power, edefSCRIPT);
3540 break;
3541
3542 case wScript9:
3543 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3544 else def = defend(wpnId, power, edefSCRIPT);
3545 break;
3546
3547 case wScript10:
3548 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3549 else def = defend(wpnId, power, edefSCRIPT);
3550 break;
3551
3552 case wWhistle:
3553 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3554 else break;
3555 break;
3556
3557 case wRefArrow:
3558 def = defend(wpnId, power, edefREFARROW);
3559 break;
3560 case wRefFire:
3561 def = defend(wpnId, power, edefREFFIRE);
3562 break;
3563 case wRefFire2:
3564 def = defend(wpnId, power, edefREFFIRE2);
3565 break;
3566
3567 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3568 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3569 //of the ten if the quest version is lower than N.
3570 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3571 //such as bool UseSeparatedScriptDefences. hah.
3572 default:
3573 //if(wpnId>=wScript1 && wpnId<=wScript10)
3574 // {
3575 // def = defend(wpnId, power, edefSCRIPT);
3576 // }
3577 // }
3578
3579 break;
3580 }
3581
3582 return def;
3583 }
3584
3585 // take damage or ignore it
3586 // 2 or -2: force wait a frame
3587 // < 0: damage (if any) dealt
3588 // > 0: blocked
3589 // 0: weapon passes through unhindered
3590 264604 int32_t enemy::takehit(weapon *w, weapon* realweap)
3591 {
3592
2/4
✓ Branch 0 taken 264604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 264604 times.
264604 if(fallclk||drownclk) return 0;
3593
2/2
✓ Branch 0 taken 69363 times.
✓ Branch 1 taken 195241 times.
264604 if(!realweap) realweap = w;
3594 264604 int32_t wpnId = w->id;
3595 264604 int32_t power = w->power;
3596 264604 int32_t wpnx = w->x;
3597 264604 int32_t wpny = w->y;
3598 264604 int32_t enemyHitWeapon = w->parentitem;
3599 int32_t wpnDir;
3600 264604 int32_t parent_item = w->parentitem;
3601
3602
2/2
✓ Branch 0 taken 264489 times.
✓ Branch 1 taken 115 times.
264604 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3603 {
3604 115 wpnId = w->useweapon;
3605 115 }
3606
3607 // If it's a boomerang that just bounced, use the opposite direction;
3608 // otherwise, it might bypass a shield. This probably won't handle
3609 // every case correctly, but it's better than having shields simply
3610 // not work against boomerangs.
3611
8/8
✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 239523 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9501 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
264604 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3612 11056 wpnDir = oppositeDir[w->dir];
3613 else
3614 253548 wpnDir = w->dir;
3615
3616
5/8
✓ Branch 0 taken 264604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264604 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7538 times.
✓ Branch 7 taken 271428 times.
264604 if(dying || clk<0 || hclk>0 || superman)
3617 7538 return 0;
3618
3619 //Prevent boomerang from writing to hitby[] for more than one frame.
3620 //This also prevents stunlock.
3621 //if ( stunclk > 0 ) return 0;
3622 //this needs a rule for boomerangs that cannot stunlock!
3623 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3624 //sigh.
3625
3626 271428 int32_t ret = -1;
3627
3628 // This obscure quest rule...
3629
5/6
✓ Branch 0 taken 92333 times.
✓ Branch 1 taken 179095 times.
✓ Branch 2 taken 88830 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88830 times.
271428 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3630 {
3631 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3632 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3633 3503 wpnDir=zc_oldrand()&3;
3634
3635
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3636 {
3637 189 wpnDir=down;
3638 189 }
3639
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3640 {
3641 285 wpnDir=right;
3642 285 }
3643
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3644 {
3645 2064 wpnDir=up;
3646 2064 }
3647 else
3648 {
3649 965 wpnDir=left;
3650 }
3651 3503 }
3652
3653 271428 int32_t xdir = dir;
3654 271428 shieldCanBlock=false;
3655
3656
4/4
✓ Branch 0 taken 260696 times.
✓ Branch 1 taken 10732 times.
✓ Branch 2 taken 2699 times.
✓ Branch 3 taken 257997 times.
272190 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3657
6/6
✓ Branch 0 taken 18367 times.
✓ Branch 1 taken 15668 times.
✓ Branch 2 taken 26198 times.
✓ Branch 3 taken 247467 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247359 times.
260696 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3658
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246340 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 245578 times.
247359 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3659 )
3660 // The hammer should already be dealt with by subclasses (Walker etc.)
3661 {
3662
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 379 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5764 times.
✓ Branch 5 taken 337 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46454 switch(wpnId)
3663 {
3664 // Weapons which shields protect against
3665 case wSword:
3666 case wWand:
3667
2/2
✓ Branch 0 taken 5762 times.
✓ Branch 1 taken 2 times.
5766 if(Hero.getCharging()>0)
3668 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3669
3670 [[fallthrough]];
3671 case wHookshot:
3672 case wHSHandle:
3673 case wBrang:
3674 6143 shieldCanBlock=true;
3675 6480 break;
3676
3677 case wBeam:
3678 case wRefBeam:
3679 // Mirror shielded enemies!
3680 #if 0
3681 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3682 {
3683 if(wpnId>wEnemyWeapons)
3684 return 0;
3685
3686 sfx(WAV_CHINK,pan(int32_t(x)));
3687 return 1;
3688 }
3689
3690 #endif
3691
3692 [[fallthrough]];
3693 case wRefRock:
3694 case wRefFireball:
3695 case wMagic:
3696 #if 0
3697 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3698 {
3699 sfx(WAV_CHINK,pan(int32_t(x)));
3700 return 3;
3701 }
3702
3703 #endif
3704
3705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(wpnId>wEnemyWeapons)
3706 return 0;
3707
3708 [[fallthrough]];
3709 case wArrow:
3710 381 case wRefArrow:
3711 default:
3712 1869 shieldCanBlock=true;
3713 1869 break;
3714
3715 // Bombs
3716 case wSBomb:
3717 case wBomb:
3718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3719 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3720 {
3721 sfx(WAV_CHINK,pan(int32_t(x)));
3722 return 0;
3723 }
3724 else break;
3725
3726 // Weapons which ignore shields
3727 case wWhistle:
3728 case wHammer:
3729 153 break;
3730
3731 // Weapons which shouldn't be removed by shields
3732 case wLitBomb:
3733 case wLitSBomb:
3734 case wWind:
3735 case wPhantom:
3736 case wSSparkle:
3737 case wBait:
3738 864 return 0;
3739
3740 case wFire:
3741 case wRefFire:
3742 case wRefFire2:
3743 ;
3744 680 }
3745 8845 }
3746
3747
8/8
✓ Branch 0 taken 103219 times.
✓ Branch 1 taken 97596 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25035 times.
✓ Branch 6 taken 2699 times.
✓ Branch 7 taken 8511 times.
265155 switch(wpnId)
3748 {
3749 case wWhistle: //No longer completely ignore whistle weapons! -Z
3750 {
3751
3752
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3753 {
3754 423 return 0; break;
3755 }
3756 else
3757 {
3758 w->power = power = itemsbuf[parent_item].misc5;
3759
3760 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3761
3762 if(def <= 0)
3763 {
3764 hp -= power;
3765 return def;
3766 }
3767 break;
3768 }
3769 break;
3770 }
3771
3772 case wPhantom:
3773 270 return 0;
3774
3775 case wLitBomb:
3776 case wLitSBomb:
3777 case wBait:
3778 case wWind:
3779 case wSSparkle:
3780 103219 return 0;
3781
3782 case wFSparkle:
3783
3784 // Only take sparkle damage if the sparkle's parent item is not
3785 // defended against.
3786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3787 {
3788 27402 int32_t p = 0;
3789 27402 int32_t f = itemsbuf[enemyHitWeapon].family;
3790
3791
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3792 {
3793 case itype_arrow:
3794 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3795
3796 break;
3797
3798 case itype_cbyrna:
3799 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3800
3801 break;
3802
3803 case itype_brang:
3804
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3805
3806 469 break;
3807
3808 default:
3809 return 0;
3810 }
3811 469 }
3812
3813 469 wpnId = wSword;
3814 469 power = game->get_hero_dmgmult()>>1;
3815 469 goto fsparkle;
3816 break;
3817
3818 case wBrang:
3819 {
3820 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3821 25035 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3822 //preventing stunlock might be best, here. -Z
3823
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19564 times.
25035 if(def >= 0) return def;
3824 19564 ret = def;
3825
3826 // Not hurt by 0-damage weapons
3827
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16380 times.
19564 if(!(flags & guy_bhit))
3828 {
3829 16380 stunclk=160;
3830
3831
3/4
✓ Branch 0 taken 16380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15069 times.
16380 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3832 {
3833
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3834 1311 goto hitclock;
3835 }
3836
3837 15069 break;
3838 }
3839
3840
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3841
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3842 else
3843 391 hp-=power;
3844
3845 3184 goto hitclock;
3846 }
3847
3848 case wHookshot:
3849 {
3850 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3851 2699 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3852
3853
2/2
✓ Branch 0 taken 956 times.
✓ Branch 1 taken 1743 times.
2699 if(def >= 0) return def;
3854 1743 ret = def;
3855
3856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1743 times.
1743 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3857
3/4
✓ Branch 0 taken 1743 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1595 times.
✓ Branch 3 taken 148 times.
1743 if(swgrab || !(flags & guy_bhit))
3858 {
3859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1595 times.
1595 if(!swgrab)
3860 1595 stunclk=160;
3861
3862
3/4
✓ Branch 0 taken 1595 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1046 times.
1595 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3863 {
3864
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3865 549 goto hitclock;
3866 }
3867
3868 1046 break;
3869 }
3870
3871
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3872 else
3873 45 hp-=power;
3874
3875 148 goto hitclock;
3876 }
3877 break;
3878
3879 case wHSHandle:
3880 {
3881
3/4
✓ Branch 0 taken 8511 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 7988 times.
8511 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3882 523 return 0;
3883
3884
3/4
✓ Branch 0 taken 5599 times.
✓ Branch 1 taken 2389 times.
✓ Branch 2 taken 2389 times.
✗ Branch 3 not taken.
7988 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2389 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3886
3887 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3888
6/8
✓ Branch 0 taken 2654 times.
✓ Branch 1 taken 5334 times.
✓ Branch 2 taken 2654 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2654 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 482 times.
✓ Branch 7 taken 2172 times.
9587 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3889
6/6
✓ Branch 0 taken 3149 times.
✓ Branch 1 taken 2667 times.
✓ Branch 2 taken 1658 times.
✓ Branch 3 taken 3663 times.
✓ Branch 4 taken 1599 times.
✓ Branch 5 taken 2064 times.
2654 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3890 2064 return 0;
3891
3892 11258 power = game->get_hero_dmgmult();
3893 11727 }
3894
3895 fsparkle:
3896
3897 [[fallthrough]];
3898 default:
3899 // Work out the defenses!
3900 {
3901 98655 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3902
3903
2/2
✓ Branch 0 taken 26477 times.
✓ Branch 1 taken 72178 times.
98655 if(def >= 0)
3904 26477 return def;
3905
2/2
✓ Branch 0 taken 71718 times.
✓ Branch 1 taken 460 times.
72178 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3906 460 ret = 0;
3907 }
3908
3909
2/2
✓ Branch 0 taken 72176 times.
✓ Branch 1 taken 2 times.
144356 if(!power)
3910 {
3911
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3912 2 hp-=1;
3913 else
3914 {
3915 // Don't make a long chain of 'stun' hits
3916 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3917 return 1;
3918
3919
3920 if(!switch_hooked)
3921 stunclk=160;
3922 break;
3923 }
3924 2 }
3925 72176 else hp-=power;
3926
3927 hitclock:
3928 77381 hclk=33;
3929
3930 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3931
2/2
✓ Branch 0 taken 34593 times.
✓ Branch 1 taken 42788 times.
77381 if((dir&2)==(w->dir&2))
3932 {
3933 42788 sclk=(w->dir<<8)+16;
3934 42788 }
3935 77381 }
3936
3937
5/6
✓ Branch 0 taken 73932 times.
✓ Branch 1 taken 19564 times.
✓ Branch 2 taken 21816 times.
✓ Branch 3 taken 71680 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21816 times.
93496 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3938 {
3939 21816 fading=fade_blue_poof;
3940 21816 }
3941
3942
6/6
✓ Branch 0 taken 88211 times.
✓ Branch 1 taken 5285 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41274 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
93496 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3943 {
3944
1/2
✓ Branch 0 taken 7632 times.
✗ Branch 1 not taken.
7632 if( hitsfx > 0 ) //user-set hit sound.
3945 {
3946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7632 times.
7632 if (!dying) //don't play the hit sound on death! -Z
3947 7632 sfx(hitsfx, pan(int32_t(x)));
3948 7632 }
3949 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3950 7632 }
3951 else //2.50.2 or earlier
3952 {
3953 85864 sfx(WAV_EHIT, pan(int32_t(x)));
3954 85864 sfx(hitsfx, pan(int32_t(x)));
3955 }
3956
2/2
✓ Branch 0 taken 93467 times.
✓ Branch 1 taken 29 times.
93496 if(family==eeGUY)
3957 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3958
3959 // Penetrating weapons
3960
4/4
✓ Branch 0 taken 91622 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 84739 times.
✓ Branch 3 taken 8757 times.
93496 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3961 {
3962 8757 int32_t item=enemyHitWeapon;
3963
3964
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7145 times.
8757 if(wpnId==wArrow)
3965 {
3966 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3967
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3968 379 return 0;
3969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3970 //if(item<0)
3971 else
3972 1233 item=current_item_id(itype_arrow);
3973 1233 }
3974
3975 else
3976 {
3977
3978 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3979
3/6
✓ Branch 0 taken 7127 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7127 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7145 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3980 return 0;
3981
3982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7145 times.
7145 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3983 else
3984 //if(item<0)
3985 7145 item=current_item_id(itype_sword);
3986 }
3987 8378 }
3988
3989 93117 return ret;
3990 268234 }
3991
3992 61541947 bool enemy::dont_draw()
3993 {
3994
6/6
✓ Branch 0 taken 61077466 times.
✓ Branch 1 taken 464481 times.
✓ Branch 2 taken 61006559 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 174746 times.
✓ Branch 5 taken 60902720 times.
61541947 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3995 639227 return true;
3996
3997
2/2
✓ Branch 0 taken 1344990 times.
✓ Branch 1 taken 59557730 times.
60902720 if(flags&guy_invisible)
3998 1344990 return true;
3999
4000
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59557298 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59557730 if(flags&guy_lens_only && !lensclk)
4001 return true;
4002
4003 59557730 return false;
4004 61541947 }
4005
4006 #define DRAW_NORMAL 2
4007 #define DRAW_CLOAKED 1
4008 #define DRAW_INVIS 0
4009 // base drawing function to be used by all derived classes instead of
4010 // sprite::draw()
4011 44774660 void enemy::draw(BITMAP *dest)
4012 {
4013 44774660 didScriptThisFrame = false; //Since there's no better place to put it
4014
6/6
✓ Branch 0 taken 44009560 times.
✓ Branch 1 taken 765100 times.
✓ Branch 2 taken 43926910 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317239 times.
✓ Branch 5 taken 43692321 times.
44774660 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4015 1082339 return;
4016
2/2
✓ Branch 0 taken 2741044 times.
✓ Branch 1 taken 40951277 times.
43692321 if(flags&guy_invisible)
4017 2741044 return;
4018
4019 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4020 // be cloaked if they have "invisible displays as cloaked" checked.
4021
4022 40951277 byte canSee = DRAW_NORMAL;
4023 //Enemy specific stuff
4024
2/2
✓ Branch 0 taken 40950113 times.
✓ Branch 1 taken 1164 times.
40951277 if ( editorflags & ENEMY_FLAG1 )
4025 {
4026 1164 canSee = DRAW_INVIS;
4027
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4028
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4029 {
4030 if (game->item[dmisc13])
4031 {
4032 canSee = DRAW_NORMAL;
4033 }
4034 //else if ( lensclk && getlensid.flags SHOWINVIS )
4035 //{
4036 //
4037 //}
4038 //else
4039 //{
4040 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4041 // //otherwisem invisible
4042 //}
4043 }
4044 1164 }
4045 //Room specific
4046 40951277 mapscr* scr = get_scr(screen_spawned);
4047
2/2
✓ Branch 0 taken 38846435 times.
✓ Branch 1 taken 2104842 times.
40951277 if (scr->flags3&fINVISROOM)
4048 {
4049
4/6
✓ Branch 0 taken 2104842 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1878838 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2330846 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4051 2104842 }
4052 //Lens check
4053
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 40923740 times.
40951277 if (lensclk)
4054 {
4055
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4056 {
4057
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4058 432 }
4059 27537 }
4060 else
4061 {
4062
2/2
✓ Branch 0 taken 40850324 times.
✓ Branch 1 taken 73416 times.
40923740 if(flags&guy_lens_only)
4063 73416 canSee = DRAW_INVIS;
4064 }
4065
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 40876697 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
40951277 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4066
3/4
✓ Branch 0 taken 40650693 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40650693 times.
✗ Branch 3 not taken.
40951277 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4067
4068
2/2
✓ Branch 0 taken 40876697 times.
✓ Branch 1 taken 74580 times.
40951277 if (canSee == DRAW_INVIS)
4069 74580 return;
4070
4071
4/4
✓ Branch 0 taken 40874322 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40874315 times.
40876697 if(fallclk||drownclk)
4072 {
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4074 {
4075 sprite::drawcloaked(dest);
4076 }
4077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4078 {
4079 2382 sprite::draw(dest);
4080 2382 }
4081 2382 return;
4082 }
4083 40874315 int32_t cshold=cs;
4084
4085
2/2
✓ Branch 0 taken 901503 times.
✓ Branch 1 taken 39972812 times.
40874315 if(dying)
4086 {
4087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901503 times.
901503 if(clk2>=19)
4088 {
4089 if(!(clk2&2))
4090 {
4091 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4092 if (canSee == DRAW_CLOAKED)
4093 {
4094 sprite::drawcloaked(dest);
4095 }
4096 else if (canSee == DRAW_NORMAL)
4097 {
4098 sprite::draw(dest);
4099 }
4100 }
4101 return;
4102 }
4103
4104 901503 flip = 0;
4105 901503 tile = wpnsbuf[spr_death].tile;
4106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901503 times.
901503 if ( do_animation )
4107 {
4108 901503 int32_t offs = 0;
4109
2/2
✓ Branch 0 taken 850354 times.
✓ Branch 1 taken 51149 times.
901503 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4110 {
4111
2/2
✓ Branch 0 taken 49521 times.
✓ Branch 1 taken 1628 times.
51149 if(clk2 > 2)
4112 {
4113 1628 spr_death_anim_clk=0;
4114 1628 clk2=1;
4115
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1614 times.
1628 if(hp > -1000)
4116 1614 death_sfx();
4117 1628 }
4118
4/4
✓ Branch 0 taken 38450 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38048 times.
51149 if(clk2==1 && spr_death_anim_clk>-1)
4119 {
4120 38048 ++clk2;
4121
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
38048 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4122
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38027 times.
38048 spr_death_anim_frm *= zc_max(1,txsz);
4123 38048 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4124
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37972 times.
38048 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4125
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38046 times.
✓ Branch 4 taken 36438 times.
✓ Branch 5 taken 1610 times.
38048 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4126 {
4127 1610 spr_death_anim_clk=-1;
4128 1610 clk2=1;
4129 1610 }
4130 38048 }
4131 51149 tile += spr_death_anim_frm;
4132 51149 }
4133
2/2
✓ Branch 0 taken 312849 times.
✓ Branch 1 taken 537505 times.
850354 else if(BSZ)
4134 {
4135
2/2
✓ Branch 0 taken 246005 times.
✓ Branch 1 taken 66844 times.
312849 offs = zc_min((15-clk2)/3,4);
4136 312849 }
4137
4/4
✓ Branch 0 taken 358415 times.
✓ Branch 1 taken 179090 times.
✓ Branch 2 taken 179079 times.
✓ Branch 3 taken 179336 times.
537505 else if(clk2>6 && clk2<=12)
4138 {
4139 179336 offs = 1;
4140 179336 }
4141
4142
2/2
✓ Branch 0 taken 455374 times.
✓ Branch 1 taken 446129 times.
901503 if(offs)
4143 {
4144
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 445679 times.
446129 offs *= zc_max(1,txsz);
4145 446129 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4146
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 445691 times.
446129 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4147 446129 }
4148 901503 tile += offs;
4149 901503 }
4150
4151
6/6
✓ Branch 0 taken 850354 times.
✓ Branch 1 taken 51149 times.
✓ Branch 2 taken 537505 times.
✓ Branch 3 taken 312849 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348323 times.
901503 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4152 553180 cs = wpnsbuf[spr_death].csets&15;
4153 else
4154 348323 cs = (((clk2+5)>>1)&3)+6;
4155 901503 }
4156
3/4
✓ Branch 0 taken 1198406 times.
✓ Branch 1 taken 38774406 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1198406 times.
39972812 else if(hclk>0 && getCanFlicker())
4157 {
4158 1198406 cs = getFlashingCSet();
4159 1198406 }
4160 //draw every other frame for flickering enemies
4161
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40626284 times.
40874315 if (is_hitflickerframe(false))
4162 {
4163
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4164
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4165 {
4166 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4167 sprite_flicker_color = temp_flicker_color;
4168 sprite::draw(dest);
4169 }
4170 248031 }
4171 else
4172 {
4173
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40401122 times.
40626284 if (canSee == DRAW_CLOAKED)
4174 {
4175 225162 sprite::drawcloaked(dest);
4176 225162 }
4177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40401122 times.
40401122 else if (canSee == DRAW_NORMAL)
4178 {
4179
1/2
✓ Branch 0 taken 40401122 times.
✗ Branch 1 not taken.
40401122 if ( frozenclock < 0 )
4180 {
4181 if ( frozentile > 0 ) tile = frozentile;
4182 loadpalset(csBOSS,frozencset);
4183 }
4184 40401122 sprite::draw(dest);
4185 40401122 }
4186 }
4187 40874315 cs=cshold;
4188 44774660 }
4189
4190 //old zc bosses
4191 40770054 void enemy::drawzcboss(BITMAP *dest)
4192 {
4193 40770054 didScriptThisFrame = false; //Since there's no better place to put it
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40770054 times.
40770054 if(dont_draw())
4195 return;
4196
4197 40770054 int32_t cshold=cs;
4198
4199
2/2
✓ Branch 0 taken 781280 times.
✓ Branch 1 taken 39988774 times.
40770054 if(dying)
4200 {
4201
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 777320 times.
781280 if(clk2>=19)
4202 {
4203
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4204 1980 sprite::drawzcboss(dest);
4205
4206 3960 return;
4207 }
4208
4209 777320 flip = 0;
4210 777320 tile = wpnsbuf[spr_death].tile;
4211
4212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777320 times.
777320 if ( do_animation )
4213 {
4214
2/2
✓ Branch 0 taken 772804 times.
✓ Branch 1 taken 4516 times.
777320 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4215 {
4216
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4217 {
4218 6 spr_death_anim_clk=0;
4219 6 clk2=1;
4220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4221 6 death_sfx();
4222 6 }
4223
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4224 {
4225 76 ++clk2;
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4228 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4230
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4231 {
4232 2 spr_death_anim_clk=-1;
4233 2 clk2=1;
4234 2 }
4235 76 }
4236 4516 tile += spr_death_anim_frm;
4237 4516 }
4238
2/2
✓ Branch 0 taken 275828 times.
✓ Branch 1 taken 496976 times.
772804 else if(BSZ)
4239
2/2
✓ Branch 0 taken 216967 times.
✓ Branch 1 taken 58861 times.
275828 tile += zc_min((15-clk2)/3,4);
4240
4/4
✓ Branch 0 taken 331281 times.
✓ Branch 1 taken 165695 times.
✓ Branch 2 taken 165538 times.
✓ Branch 3 taken 165743 times.
496976 else if(clk2>6 && clk2<=12)
4241 165743 ++tile;
4242 777320 }
4243
4244
6/6
✓ Branch 0 taken 772804 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496976 times.
✓ Branch 3 taken 275828 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313104 times.
777320 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4245 464216 cs = wpnsbuf[spr_death].csets&15;
4246 else
4247 313104 cs = (((clk2+5)>>1)&3)+6;
4248 777320 }
4249
2/2
✓ Branch 0 taken 38781760 times.
✓ Branch 1 taken 1207014 times.
39988774 else if(hclk>0)
4250 {
4251 1207014 cs = getFlashingCSet();
4252 1207014 }
4253
4254 40766094 mapscr* scr = get_scr(screen_spawned);
4255
4256
3/4
✓ Branch 0 taken 1979262 times.
✓ Branch 1 taken 38786832 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40773637 if((scr->flags3&fINVISROOM) &&
4257
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 1971719 times.
1979262 !(current_item(itype_amulet)) &&
4258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4259 7543 lensclk) && family!=eeGANON)
4260 {
4261 7543 sprite::drawcloaked(dest);
4262 7543 }
4263 else
4264 {
4265
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40735078 times.
40758551 if (is_hitflickerframe(true))
4266 {
4267
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4268
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4269 {
4270 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4271 sprite_flicker_color = temp_flicker_color;
4272 sprite::drawzcboss(dest);
4273 }
4274 23473 }
4275 else
4276 40735078 sprite::drawzcboss(dest);
4277 }
4278
4279 40766094 cs=cshold;
4280 40770054 }
4281
4282
4283 // similar to the overblock function--can do up to a 32x32 sprite
4284 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4285 322496 void enemy::drawblock(BITMAP *dest,int32_t mask)
4286 {
4287 322496 int32_t thold=tile;
4288 322496 int32_t t1=tile;
4289 322496 int32_t t2=tile+20;
4290 322496 int32_t t3=tile+1;
4291 322496 int32_t t4=tile+21;
4292
4293
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 322496 times.
322496 switch(mask)
4294 {
4295 case 1:
4296 enemy::drawzcboss(dest);
4297 break;
4298
4299 case 3:
4300 if(flip&2)
4301 zc_swap(t1,t2);
4302
4303 tile=t1;
4304 enemy::drawzcboss(dest);
4305 tile=t2;
4306 yofs+=16;
4307 enemy::drawzcboss(dest);
4308 yofs-=16;
4309 break;
4310
4311 case 5:
4312 t2=tile+1;
4313
4314 if(flip&1)
4315 zc_swap(t1,t2);
4316
4317 tile=t1;
4318 enemy::drawzcboss(dest);
4319 tile=t2;
4320 xofs+=16;
4321 enemy::drawzcboss(dest);
4322 xofs-=16;
4323 break;
4324
4325 case 15:
4326
2/2
✓ Branch 0 taken 315740 times.
✓ Branch 1 taken 6756 times.
322496 if(flip&1)
4327 {
4328 6756 zc_swap(t1,t3);
4329 6756 zc_swap(t2,t4);
4330 6756 }
4331
4332
1/2
✓ Branch 0 taken 322496 times.
✗ Branch 1 not taken.
322496 if(flip&2)
4333 {
4334 zc_swap(t1,t2);
4335 zc_swap(t3,t4);
4336 }
4337
4338 322496 tile=t1;
4339 322496 enemy::drawzcboss(dest);
4340 322496 tile=t2;
4341 322496 yofs+=16;
4342 322496 enemy::drawzcboss(dest);
4343 322496 yofs-=16;
4344 322496 tile=t3;
4345 322496 xofs+=16;
4346 322496 enemy::drawzcboss(dest);
4347 322496 tile=t4;
4348 322496 yofs+=16;
4349 322496 enemy::drawzcboss(dest);
4350 322496 xofs-=16;
4351 322496 yofs-=16;
4352 322496 break;
4353 }
4354
4355 322496 tile=thold;
4356 322496 }
4357
4358 20210697 void enemy::drawshadow(BITMAP *dest, bool translucent)
4359 {
4360
4/4
✓ Branch 0 taken 18226480 times.
✓ Branch 1 taken 1984217 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 17699562 times.
20210697 if(dont_draw() || isSideViewGravity())
4361 {
4362 2511135 return;
4363 }
4364
4365
2/2
✓ Branch 0 taken 325294 times.
✓ Branch 1 taken 17374268 times.
17699562 if(dying)
4366 {
4367 325294 return;
4368 }
4369
4370 17374268 mapscr* scr = get_scr(screen_spawned);
4371
4/4
✓ Branch 0 taken 1645102 times.
✓ Branch 1 taken 15729166 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17027258 times.
17374268 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4372 17374268 (darkroom))
4373 {
4374 347010 return;
4375 }
4376 else
4377 {
4378
4/4
✓ Branch 0 taken 16428707 times.
✓ Branch 1 taken 598551 times.
✓ Branch 2 taken 16381603 times.
✓ Branch 3 taken 47104 times.
17027258 if(enemycanfall(id, false) && shadowtile == 0)
4379 47104 shadowtile = wpnsbuf[spr_shadow].tile;
4380
4381
5/6
✓ Branch 0 taken 16083376 times.
✓ Branch 1 taken 943882 times.
✓ Branch 2 taken 16083376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15484825 times.
✓ Branch 5 taken 598551 times.
17027258 if(z>0 || fakez>0 || !enemycanfall(id, false))
4382 {
4383
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1542158 times.
1542433 if(!shadow_overpit(this))
4384 1542158 sprite::drawshadow(dest,translucent);
4385 1542433 }
4386 }
4387 20210697 }
4388
4389 127967 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4390 {
4391 127967 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4392
4393
1/2
✓ Branch 0 taken 127967 times.
✗ Branch 1 not taken.
127967 if(sub!=NULL)
4394 {
4395 127967 xofs-=mx;
4396 127967 yofs-=my;
4397 127967 enemy::draw(sub);
4398 127967 xofs+=mx;
4399 127967 yofs+=my;
4400 127967 destroy_bitmap(sub);
4401 127967 }
4402 else
4403 enemy::draw(dest);
4404 127967 }
4405
4406 9 void enemy::init_size_flags()
4407 {
4408
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4409
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4410
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4411
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4413
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4414
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4415
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4416
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4417 {
4418 yofs = (int32_t)d->yofs;
4419 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4420 }
4421
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4422 9 }
4423
4424 // override hit detection to check for invicibility, stunned, etc
4425 112309433 bool enemy::hit()
4426 {
4427
4/4
✓ Branch 0 taken 110985371 times.
✓ Branch 1 taken 1324062 times.
✓ Branch 2 taken 109177347 times.
✓ Branch 3 taken 1808024 times.
112309433 if(dying || hclk>0) return false;
4428 109177347 return sprite::hit();
4429 112309433 }
4430 730351 bool enemy::hit(sprite *s)
4431 {
4432
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4433 713374 return sprite::hit(s);
4434 730351 }
4435
4436 44563926 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4437 {
4438
2/2
✓ Branch 0 taken 3957519 times.
✓ Branch 1 taken 40606407 times.
44563926 if(!hit()) return false;
4439 40606407 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4440 44563926 }
4441 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4442 {
4443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4444 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4445 78011 }
4446
4447 11172909 bool enemy::hit(weapon *w)
4448 {
4449
2/2
✓ Branch 0 taken 1195364 times.
✓ Branch 1 taken 9977545 times.
11172909 if(!hit()) return false;
4450
4451
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3330163 times.
9977545 if (replay_version_check(0, 14))
4452 {
4453
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4454 225051 return false;
4455 6422331 return sprite::hit(w);
4456 }
4457 3330163 return w->hit(this);
4458 11172909 }
4459
4460 9488584 bool enemy::can_pitfall(bool checkspawning)
4461 {
4462
4/4
✓ Branch 0 taken 9468652 times.
✓ Branch 1 taken 19932 times.
✓ Branch 2 taken 9457967 times.
✓ Branch 3 taken 30617 times.
9488584 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4463
2/2
✓ Branch 0 taken 9440294 times.
✓ Branch 1 taken 17673 times.
9457967 switch(guysbuf[id&0xFFF].family)
4464 {
4465 case eeAQUA:
4466 case eeDIG:
4467 case eeDONGO:
4468 case eeFAIRY:
4469 case eeGANON:
4470 case eeGHOMA:
4471 case eeGLEEOK:
4472 case eeGUY:
4473 case eeLANM:
4474 case eeMANHAN:
4475 case eeMOLD:
4476 case eeNONE:
4477 case eePATRA:
4478 case eeZORA:
4479 17673 return false; //Disallowed types
4480 default:
4481 9440294 return true;
4482 }
4483 9488584 }
4484 //Handle death
4485 37840448 void enemy::try_death(bool force_kill)
4486 {
4487
8/8
✓ Branch 0 taken 37783879 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37783868 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43486 times.
✓ Branch 5 taken 37740382 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43485 times.
37840448 if(!dying && (force_kill || (hp<=0 && !immortal)))
4488 {
4489 43496 std::vector<int32_t> &ev = FFCore.eventData;
4490 43496 ev.clear();
4491 43496 ev.push_back(10000);
4492 43496 ev.push_back(getUID());
4493
4494 43496 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4495 43496 bool isSaved = !ev[0];
4496 43496 ev.clear();
4497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43496 times.
43496 if(isSaved) return;
4498
4499
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43446 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43496 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4500 {
4501
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4502 {
4503
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4504 {
4505
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4506 {
4507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4508 {
4509 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4510 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4511 }
4512 else
4513 {
4514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4515 {
4516 items.spr(i)->x = x+(txsz-1)*8;
4517 items.spr(i)->y = y-2+(tysz-1)*8;
4518 }
4519 else
4520 {
4521 3 items.spr(i)->x = x;
4522 3 items.spr(i)->y = y - 2;
4523 }
4524 }
4525 3 items.spr(i)->z = z;
4526 3 items.spr(i)->fakez = fakez;
4527 3 }
4528 else
4529 {
4530 41 items.spr(i)->x = x;
4531 41 items.spr(i)->y = y - 2;
4532 }
4533 44 }
4534 51 }
4535 44 }
4536
4537 43496 dying=true;
4538
4539
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43464 times.
43496 if(fading==fade_flash_die)
4540 32 clk2=19+18*4;
4541 else
4542 {
4543 43464 clk2 = BSZ ? 15 : 19;
4544
4545
2/2
✓ Branch 0 taken 20895 times.
✓ Branch 1 taken 22569 times.
43464 if(fading!=fade_blue_poof)
4546 22569 fading=0;
4547 }
4548
4549
2/2
✓ Branch 0 taken 43446 times.
✓ Branch 1 taken 50 times.
43496 if(itemguy)
4550 {
4551 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4552 50 item_set=0;
4553 50 }
4554
6/6
✓ Branch 0 taken 42443 times.
✓ Branch 1 taken 1053 times.
✓ Branch 2 taken 33775 times.
✓ Branch 3 taken 8668 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32347 times.
43496 if (screen_spawned < 128 && count_enemy && !script_spawned)
4555 32347 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4556 43496 }
4557 37840448 }
4558
4559 // --==**==--
4560
4561 // Movement routines that can be used by derived classes as needed
4562
4563 // --==**==--
4564
4565 552981 void enemy::fix_coords(bool bound)
4566 {
4567
1/2
✓ Branch 0 taken 552981 times.
✗ Branch 1 not taken.
552981 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4568
1/2
✓ Branch 0 taken 552981 times.
✗ Branch 1 not taken.
552981 if(moveflags & move_ignore_screenedge) bound = false;
4569
4570
2/2
✓ Branch 0 taken 80671 times.
✓ Branch 1 taken 472310 times.
552981 if(bound)
4571 {
4572 472310 int w = world_w;
4573 472310 int h = world_h;
4574
4575
1/2
✓ Branch 0 taken 472310 times.
✗ Branch 1 not taken.
472310 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4576 {
4577
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 472308 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
472310 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4578
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 472308 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
472310 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4579 472310 }
4580 else
4581 {
4582 x=vbound(x, 0, w-16);
4583 y=vbound(y, 0, h-16);
4584 }
4585 472310 }
4586
4587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552981 times.
552981 if(!OUTOFBOUNDS(id, x, y))
4588 {
4589 552981 do_fix(x, 16, true);
4590
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 551842 times.
552981 if(isSideViewGravity())
4591 1139 do_fix(y,8,true);
4592 551842 else do_fix(y,16,true);
4593 552981 }
4594 552981 }
4595 9153 bool enemy::cannotpenetrate()
4596 {
4597
4/4
✓ Branch 0 taken 8972 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8934 times.
9153 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4598 }
4599
4600 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4601 {
4602 bool ok;
4603 562 int32_t dx = 0, dy = 0;
4604 562 int32_t sv = 8;
4605
4606 //Why is this here??? Why is it needed???
4607 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4608
4609
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4610 {
4611 case 8:
4612 case up:
4613
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4614 return false;
4615
4616 69 dy = dy1-s;
4617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4619 69 break;
4620
4621 case 12:
4622 case down:
4623
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4624 return false;
4625
4626 51 dy = dy2+s;
4627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4628 51 break;
4629
4630 case 14:
4631 case left:
4632 47 dx = dx1-s;
4633 47 sv = ((isSideViewGravity())?7:8);
4634
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4635
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4636 47 break;
4637
4638 case 10:
4639 case right:
4640 85 dx = dx2+s;
4641 85 sv = ((isSideViewGravity())?7:8);
4642
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4643 85 break;
4644
4645 case 9:
4646 case r_up:
4647 94 dx = dx2+s;
4648 94 dy = dy1-s;
4649
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4651 94 break;
4652
4653 case 11:
4654 case r_down:
4655 78 dx = dx2+s;
4656 78 dx = dy2+s;
4657
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4659 78 break;
4660
4661 case 13:
4662 case l_down:
4663 57 dx = dx1-s;
4664 57 dy = dy2+s;
4665
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4667 57 break;
4668
4669 case 15:
4670 case l_up:
4671 81 dx = dx1-s;
4672 81 dy = dy1-s;
4673
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4675 81 break;
4676
4677 default:
4678 db=99;
4679 return true;
4680 }
4681
4682 562 return ok;
4683 562 }
4684
4685
4686
4687
4688 // returns true if next step is ok, false if there is something there
4689 7321591 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4690 {
4691 7321591 bool ok = false; //initialise the var, son't just declare it
4692 7321591 int32_t dx = 0, dy = 0;
4693 7321591 int32_t sv = 8;
4694 7321591 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4695 //Why is this here??? Why is it needed???
4696 7321591 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7321591 times.
7321591 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7321591 times.
7321591 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4699
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7321578 times.
7321591 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4700
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7321578 times.
7321591 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4701 7321591 bool offgrid = OFFGRID_ENEMY;
4702
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7314300 times.
7321591 if(!offgrid)
4703 {
4704 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4705
1/2
✓ Branch 0 taken 7314300 times.
✗ Branch 1 not taken.
7314300 if(usehei<16)usehei=16;
4706
1/2
✓ Branch 0 taken 7314300 times.
✗ Branch 1 not taken.
7314300 if(usewid<16)usewid=16;
4707 7314300 }
4708
9/9
✓ Branch 0 taken 1325075 times.
✓ Branch 1 taken 1103143 times.
✓ Branch 2 taken 1218613 times.
✓ Branch 3 taken 1209521 times.
✓ Branch 4 taken 538033 times.
✓ Branch 5 taken 639968 times.
✓ Branch 6 taken 601117 times.
✓ Branch 7 taken 566536 times.
✓ Branch 8 taken 119585 times.
7321591 switch(ndir) //need to check every 8 pixels between two points
4709 {
4710 case 8:
4711 case up:
4712 {
4713
4/4
✓ Branch 0 taken 150808 times.
✓ Branch 1 taken 1174267 times.
✓ Branch 2 taken 150148 times.
✓ Branch 3 taken 660 times.
1325075 if(enemycanfall(id) && isSideViewGravity())
4714 660 return false;
4715
4716 1324415 dy = dy1-s;
4717
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1323935 times.
1324415 special = (special==spw_clipbottomright)?spw_none:special;
4718 1324415 tries = usewid/(offgrid ? 8 : 16);
4719
4720
2/2
✓ Branch 0 taken 1125322 times.
✓ Branch 1 taken 1325065 times.
2450387 for ( ; tries > 0; --tries )
4721 {
4722
2/2
✓ Branch 0 taken 196469 times.
✓ Branch 1 taken 1128596 times.
1325065 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4723 1325065 try_x += (offgrid ? 8 : 16);
4724
2/2
✓ Branch 0 taken 1125972 times.
✓ Branch 1 taken 199093 times.
1325065 if (!ok) break;
4725 1125972 }
4726
2/2
✓ Branch 0 taken 1125322 times.
✓ Branch 1 taken 199093 times.
1324415 if(!ok) break;
4727
1/2
✓ Branch 0 taken 1125322 times.
✗ Branch 1 not taken.
1125322 if((usewid%16)>0) //Uneven width
4728 {
4729 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4730 }
4731 1125322 break;
4732 }
4733 case 12:
4734 case down:
4735 {
4736
4/4
✓ Branch 0 taken 180701 times.
✓ Branch 1 taken 922442 times.
✓ Branch 2 taken 179975 times.
✓ Branch 3 taken 726 times.
1103143 if(enemycanfall(id) && isSideViewGravity())
4737 726 return false;
4738
4739 1102417 dy = dy2+s;
4740 1102417 tries = usewid/(offgrid ? 8 : 16);
4741
2/2
✓ Branch 0 taken 897380 times.
✓ Branch 1 taken 1103201 times.
2000581 for ( ; tries > 0; --tries )
4742 {
4743
3/4
✓ Branch 0 taken 204289 times.
✓ Branch 1 taken 898912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 898912 times.
1103201 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4744 1103201 try_x += (offgrid ? 8 : 16);
4745
2/2
✓ Branch 0 taken 898164 times.
✓ Branch 1 taken 205037 times.
1103201 if (!ok) break;
4746 898164 }
4747
2/2
✓ Branch 0 taken 897380 times.
✓ Branch 1 taken 205037 times.
1102417 if(!ok) break;
4748
1/2
✓ Branch 0 taken 897380 times.
✗ Branch 1 not taken.
897380 if((usewid%16)>0) //Uneven width
4749 {
4750 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4751 }
4752 897380 break;
4753 }
4754 case 14:
4755 case left:
4756 {
4757 1218613 dx = dx1-s;
4758 1218613 sv = ((isSideViewGravity())?7:0);
4759
4/4
✓ Branch 0 taken 1217990 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1216222 times.
1218613 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4760 1218613 tries = usehei/(offgrid ? 8 : 16);
4761
2/2
✓ Branch 0 taken 1022905 times.
✓ Branch 1 taken 1219530 times.
2242435 for ( ; tries > 0; --tries )
4762 {
4763
2/2
✓ Branch 0 taken 194523 times.
✓ Branch 1 taken 1025007 times.
1219530 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4764 1219530 try_y += (offgrid ? 8 : 16);
4765
2/2
✓ Branch 0 taken 1023822 times.
✓ Branch 1 taken 195708 times.
1219530 if (!ok) break;
4766 1023822 }
4767
2/2
✓ Branch 0 taken 1022905 times.
✓ Branch 1 taken 195708 times.
1218613 if(!ok) break;
4768
1/2
✓ Branch 0 taken 1022905 times.
✗ Branch 1 not taken.
1022905 if((usehei%16)>0) //Uneven height
4769 {
4770 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4771 }
4772 1022905 break;
4773 }
4774 case 10:
4775 case right:
4776 {
4777 1209521 dx = dx2+s;
4778 1209521 sv = ((isSideViewGravity())?7:0);
4779 1209521 tries = usehei/(offgrid ? 8 : 16);
4780
2/2
✓ Branch 0 taken 1024685 times.
✓ Branch 1 taken 1210415 times.
2235100 for ( ; tries > 0; --tries )
4781 {
4782
3/4
✓ Branch 0 taken 183481 times.
✓ Branch 1 taken 1026934 times.
✓ Branch 2 taken 1026934 times.
✗ Branch 3 not taken.
1210415 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4783 1210415 try_y += (offgrid ? 8 : 16);
4784
2/2
✓ Branch 0 taken 1025579 times.
✓ Branch 1 taken 184836 times.
1210415 if (!ok) break;
4785 1025579 }
4786
2/2
✓ Branch 0 taken 1024685 times.
✓ Branch 1 taken 184836 times.
1209521 if(!ok) break;
4787
1/2
✓ Branch 0 taken 1024685 times.
✗ Branch 1 not taken.
1024685 if((usehei%16)>0) //Uneven height
4788 {
4789 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4790 }
4791 1024685 break;
4792 }
4793 case 9:
4794 case r_up:
4795 {
4796 538033 dx = dx2+s;
4797 538033 dy = dy1-s;
4798 538033 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4799 538033 sv = ((isSideViewGravity())?7:0);
4800
2/2
✓ Branch 0 taken 521014 times.
✓ Branch 1 taken 538033 times.
1059047 for ( ; tries_x > 0; --tries_x )
4801 {
4802 538033 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4803 538033 try_y = 0;
4804
2/2
✓ Branch 0 taken 521014 times.
✓ Branch 1 taken 538033 times.
1059047 for ( ; tries_y > 0; --tries_y )
4805 {
4806
4/4
✓ Branch 0 taken 529781 times.
✓ Branch 1 taken 8252 times.
✓ Branch 2 taken 524355 times.
✓ Branch 3 taken 5426 times.
1062388 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4807
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 521963 times.
524355 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4808 538033 try_y += (offgrid ? 8 : 16);
4809
2/2
✓ Branch 0 taken 521014 times.
✓ Branch 1 taken 17019 times.
538033 if (!ok) break;
4810 521014 }
4811
2/2
✓ Branch 0 taken 521014 times.
✓ Branch 1 taken 17019 times.
538033 if (!ok) break;
4812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 521014 times.
521014 if((usehei%16)>0) //Uneven height
4813 {
4814 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4815 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4816 }
4817 521014 try_x += (offgrid ? 8 : 16);
4818 521014 }
4819
2/2
✓ Branch 0 taken 521014 times.
✓ Branch 1 taken 17019 times.
538033 if(!ok) break;
4820
1/2
✓ Branch 0 taken 521014 times.
✗ Branch 1 not taken.
521014 if((usewid%16)>0) //Uneven width
4821 {
4822 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4823 try_y = 0;
4824 for ( ; tries_y > 0; --tries_y )
4825 {
4826 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4827 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4828 try_y += (offgrid ? 8 : 16);
4829 if (!ok) break;
4830 }
4831 if (!ok) break;
4832 if((usehei%16)>0) //Uneven height
4833 {
4834 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4835 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4836 }
4837 }
4838 521014 break;
4839 }
4840 case 11:
4841 case r_down:
4842 {
4843 639968 dx = dx2+s;
4844 639968 dx = dy2+s;
4845 639968 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4846 //sv = ((isSideViewGravity())?7:0);
4847
2/2
✓ Branch 0 taken 624614 times.
✓ Branch 1 taken 639968 times.
1264582 for ( ; tries_x > 0; --tries_x )
4848 {
4849 639968 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4850 639968 try_y = 0;
4851
2/2
✓ Branch 0 taken 624614 times.
✓ Branch 1 taken 639968 times.
1264582 for ( ; tries_y > 0; --tries_y )
4852 {
4853
4/4
✓ Branch 0 taken 638463 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 625680 times.
✓ Branch 3 taken 12783 times.
1265648 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4854
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 625575 times.
625680 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4855 639968 try_y += (offgrid ? 8 : 16);
4856
2/2
✓ Branch 0 taken 624614 times.
✓ Branch 1 taken 15354 times.
639968 if (!ok) break;
4857 624614 }
4858
2/2
✓ Branch 0 taken 624614 times.
✓ Branch 1 taken 15354 times.
639968 if (!ok) break;
4859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 624614 times.
624614 if((usehei%16)>0) //Uneven height
4860 {
4861 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4862 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4863 }
4864 624614 try_x += (offgrid ? 8 : 16);
4865 624614 }
4866
2/2
✓ Branch 0 taken 624614 times.
✓ Branch 1 taken 15354 times.
639968 if(!ok) break;
4867
1/2
✓ Branch 0 taken 624614 times.
✗ Branch 1 not taken.
624614 if((usewid%16)>0) //Uneven width
4868 {
4869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4870 try_y = 0;
4871 for ( ; tries_y > 0; --tries_y )
4872 {
4873 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4874 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4875 try_y += (offgrid ? 8 : 16);
4876 if (!ok) break;
4877 }
4878 if (!ok) break;
4879 if((usehei%16)>0) //Uneven height
4880 {
4881 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4882 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4883 }
4884 }
4885 624614 break;
4886 }
4887 case 13:
4888 case l_down:
4889 {
4890 601117 dx = dx1-s;
4891 601117 dy = dy2+s;
4892 601117 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4893 //sv = ((isSideViewGravity())?7:0);
4894
2/2
✓ Branch 0 taken 584104 times.
✓ Branch 1 taken 601117 times.
1185221 for ( ; tries_x > 0; --tries_x )
4895 {
4896 601117 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4897 601117 try_y = 0;
4898
2/2
✓ Branch 0 taken 584104 times.
✓ Branch 1 taken 601117 times.
1185221 for ( ; tries_y > 0; --tries_y )
4899 {
4900
4/4
✓ Branch 0 taken 589235 times.
✓ Branch 1 taken 11882 times.
✓ Branch 2 taken 584972 times.
✓ Branch 3 taken 4263 times.
1186089 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4901
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 584404 times.
584972 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4902 601117 try_y += (offgrid ? 8 : 16);
4903
2/2
✓ Branch 0 taken 584104 times.
✓ Branch 1 taken 17013 times.
601117 if (!ok) break;
4904 584104 }
4905
2/2
✓ Branch 0 taken 584104 times.
✓ Branch 1 taken 17013 times.
601117 if (!ok) break;
4906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 584104 times.
584104 if((usehei%16)>0) //Uneven height
4907 {
4908 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4909 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4910 }
4911 584104 try_x += (offgrid ? 8 : 16);
4912 584104 }
4913
2/2
✓ Branch 0 taken 584104 times.
✓ Branch 1 taken 17013 times.
601117 if(!ok) break;
4914
1/2
✓ Branch 0 taken 584104 times.
✗ Branch 1 not taken.
584104 if((usewid%16)>0) //Uneven width
4915 {
4916 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4917 try_y = 0;
4918 for ( ; tries_y > 0; --tries_y )
4919 {
4920 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4921 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4922 try_y += (offgrid ? 8 : 16);
4923 if (!ok) break;
4924 }
4925 if (!ok) break;
4926 if((usehei%16)>0) //Uneven height
4927 {
4928 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4929 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4930 }
4931 }
4932 584104 break;
4933 }
4934 case 15:
4935 case l_up:
4936 {
4937 566536 dx = dx1-s;
4938 566536 dy = dy1-s;
4939 566536 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4940 566536 sv = ((isSideViewGravity())?7:0);
4941
2/2
✓ Branch 0 taken 550646 times.
✓ Branch 1 taken 566536 times.
1117182 for ( ; tries_x > 0; --tries_x )
4942 {
4943 566536 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4944 566536 try_y = 0;
4945
2/2
✓ Branch 0 taken 550646 times.
✓ Branch 1 taken 566536 times.
1117182 for ( ; tries_y > 0; --tries_y )
4946 {
4947
4/4
✓ Branch 0 taken 557914 times.
✓ Branch 1 taken 8622 times.
✓ Branch 2 taken 553952 times.
✓ Branch 3 taken 3962 times.
1120488 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4948
2/2
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 551515 times.
553952 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4949 566536 try_y += (offgrid ? 8 : 16);
4950
2/2
✓ Branch 0 taken 550646 times.
✓ Branch 1 taken 15890 times.
566536 if (!ok) break;
4951 550646 }
4952
2/2
✓ Branch 0 taken 550646 times.
✓ Branch 1 taken 15890 times.
566536 if (!ok) break;
4953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550646 times.
550646 if((usehei%16)>0) //Uneven height
4954 {
4955 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4956 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4957 }
4958 550646 try_x += (offgrid ? 8 : 16);
4959 550646 }
4960
2/2
✓ Branch 0 taken 550646 times.
✓ Branch 1 taken 15890 times.
566536 if(!ok) break;
4961
1/2
✓ Branch 0 taken 550646 times.
✗ Branch 1 not taken.
550646 if((usewid%16)>0) //Uneven width
4962 {
4963 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4964 try_y = 0;
4965 for ( ; tries_y > 0; --tries_y )
4966 {
4967 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4968 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4969 try_y += (offgrid ? 8 : 16);
4970 if (!ok) break;
4971 }
4972 if (!ok) break;
4973 if((usehei%16)>0) //Uneven height
4974 {
4975 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4976 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4977 }
4978 }
4979 550646 break;
4980 }
4981 default:
4982 119585 db=99;
4983 119585 return true;
4984 }
4985
4986 7200620 return ok;
4987 7321591 }
4988
4989
4990 4630527 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4991 {
4992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4630527 times.
4630527 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4630527 times.
4630527 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4994
1/2
✓ Branch 0 taken 4630527 times.
✗ Branch 1 not taken.
4630527 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4995
1/2
✓ Branch 0 taken 4630527 times.
✗ Branch 1 not taken.
4630527 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4996 4630527 --usewid;
4997 4630527 --usehei;
4998 4630527 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4999 }
5000
5001 1232771 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5002 {
5003 1232771 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5004
5005
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1225952 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1232771 if(special==spw_clipright&&ndir==right)
5006 {
5007 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5008 1798 }
5009
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1232766 times.
1232771 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5010
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1232766 times.
1232771 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5011
1/2
✓ Branch 0 taken 1232771 times.
✗ Branch 1 not taken.
1232771 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5012
1/2
✓ Branch 0 taken 1232771 times.
✗ Branch 1 not taken.
1232771 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5013 1232771 --usewid;
5014 1232771 --usehei;
5015
2/2
✓ Branch 0 taken 708718 times.
✓ Branch 1 taken 524053 times.
1232771 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5016 }
5017
5018 136101 bool enemy::canmove(int32_t ndir, bool kb)
5019 {
5020 136101 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5021 }
5022
5023 // 8-directional
5024 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5025 {
5026 562 int32_t ndir=0;
5027
5028 // can move straight, check if it wants to turn
5029
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5030 {
5031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5032 {
5033 int32_t w = Lwpns.idFirst(wBait);
5034
5035 if(w>=0)
5036 {
5037 int32_t bx = Lwpns.spr(w)->x;
5038 int32_t by = Lwpns.spr(w)->y;
5039
5040 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5041
5042 if(abs(int32_t(y)-by)>14)
5043 {
5044 if(ndir>0) // Already left or right
5045 {
5046 // Making the diagonal directions
5047 ndir += (by<y) ? 2 : 4;
5048 }
5049 else
5050 {
5051 ndir = (by<y) ? up : down;
5052 }
5053 }
5054
5055 if(canmove(ndir,special,false))
5056 {
5057 dir=ndir;
5058 return;
5059 }
5060 }
5061 }
5062
5063 // Homing added.
5064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5065 {
5066 ndir = lined_up(8,true);
5067
5068 if(ndir>=0 && canmove(ndir,special,false))
5069 {
5070 dir=ndir;
5071 }
5072
5073 return;
5074 }
5075
5076 549 int32_t r=zc_oldrand();
5077
5078
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5079 {
5080 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5081 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5082
5083
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5084 525 dir=ndir;
5085
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5086 19 dir=ndir2;
5087
5088
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5089 // due to numerous lost fractional components. -L
5090 {
5091 x.doFloor();
5092 y.doFloor();
5093 }
5094 549 }
5095
5096 549 return;
5097 }
5098
5099 // can't move straight, must turn
5100 13 int32_t i=0;
5101
5102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5103 {
5104 20 ndir=(zc_oldrand()&7)+8;
5105
5106
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5107 13 break;
5108 7 }
5109
5110
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5111 {
5112 for(ndir=8; ndir<16; ndir++)
5113 {
5114 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5115 goto ok;
5116 }
5117
5118 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5119 }
5120
5121 ok:
5122 13 dir=ndir;
5123 13 x.doFloor();
5124 13 y.doFloor();
5125 562 }
5126
5127 578105 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5128 {
5129 578105 int32_t ndir=0;
5130
5131 // can move straight, check if it wants to turn
5132
2/2
✓ Branch 0 taken 545547 times.
✓ Branch 1 taken 32558 times.
578105 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5133 {
5134
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 545340 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
545547 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5135 {
5136 101 int32_t i = Lwpns.idFirst(wBait);
5137
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5138 {
5139 weapon *w = (weapon*)Lwpns.spr(i);
5140 if (get_qr(qr_FIND_CLOSEST_BAIT))
5141 {
5142 int32_t currentrange;
5143 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5144 else currentrange = -1;
5145 int curid = i;
5146 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5147 for(; i<Lwpns.Count(); ++i)
5148 {
5149 weapon *lw = (weapon*)Lwpns.spr(i);
5150 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5151 {
5152 currentrange = distance(x, y, lw->x, lw->y);
5153 curid = i;
5154 }
5155 }
5156 i = curid;
5157 if (currentrange == -1) i = -1;
5158 }
5159 else
5160 {
5161 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5162 }
5163 if(i>=0)
5164 {
5165 int32_t bx = Lwpns.spr(i)->x;
5166 int32_t by = Lwpns.spr(i)->y;
5167
5168 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5169
5170 if(abs(int32_t(y)-by)>14)
5171 {
5172 if(ndir>0) // Already left or right
5173 {
5174 // Making the diagonal directions
5175 ndir += (by<y) ? 2 : 4;
5176 }
5177 else
5178 {
5179 ndir = (by<y) ? up : down;
5180 }
5181 }
5182 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5183 if(canmove(ndir,special,false))
5184 {
5185 dir=ndir;
5186 return;
5187 }
5188 }
5189 }
5190 101 }
5191
5192 // Homing added.
5193
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 515921 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
545547 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5194 {
5195 14216 ndir = lined_up(8,true);
5196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5197
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5198 {
5199 5852 dir=ndir;
5200 5852 }
5201
5202 14216 return;
5203 }
5204
5205 531331 int32_t r=zc_oldrand();
5206
5207
4/4
✓ Branch 0 taken 338727 times.
✓ Branch 1 taken 192604 times.
✓ Branch 2 taken 179053 times.
✓ Branch 3 taken 159674 times.
531331 if(newrate>0 && !(r%newrate))
5208 {
5209 159674 ndir = ((dir+((r&64)?-1:1))&7)+8;
5210 159674 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5211
5212
2/2
✓ Branch 0 taken 153880 times.
✓ Branch 1 taken 5794 times.
159674 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5213 153880 dir=ndir;
5214
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4937 times.
5794 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5215 4937 dir=ndir2;
5216
5217
4/4
✓ Branch 0 taken 153880 times.
✓ Branch 1 taken 5794 times.
✓ Branch 2 taken 146571 times.
✓ Branch 3 taken 7309 times.
159674 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5218 // due to numerous lost fractional components. -L
5219 {
5220 7309 x.doFloor();
5221 7309 y.doFloor();
5222 7309 }
5223 159674 }
5224
5225 531331 return;
5226 }
5227
5228 // can't move straight, must turn
5229 32558 int32_t i=0;
5230
5231 // TODO: speed this up!
5232
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 60967 times.
61036 for(; i<32; i++) // Try random dir
5233 {
5234 60967 ndir=(zc_oldrand()&7)+8;
5235
5236
2/2
✓ Branch 0 taken 28478 times.
✓ Branch 1 taken 32489 times.
60967 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5237 32489 break;
5238 28478 }
5239
5240
2/2
✓ Branch 0 taken 32489 times.
✓ Branch 1 taken 69 times.
32611 if(i==32)
5241 {
5242
2/2
✓ Branch 0 taken 458 times.
✓ Branch 1 taken 53 times.
511 for(ndir=8; ndir<16; ndir++)
5243 {
5244
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 16 times.
458 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5245 16 goto ok;
5246 442 }
5247
5248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5249 53 }
5250
5251 ok:
5252 32558 dir=ndir;
5253 32558 x.doFloor();
5254 32558 y.doFloor();
5255 578105 }
5256
5257 571630 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5258 {
5259 571630 newdir_8(newrate,newhoming,special,0,-8,15,15);
5260 571630 }
5261
5262 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5263 {
5264 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5265 562 }
5266
5267 // makes the enemy slide backwards when hit
5268 // sclk: first byte is clk, second byte is dir
5269 // makes the enemy slide backwards when hit
5270 // sclk: first byte is clk, second byte is dir
5271 15577561 int32_t enemy::slide()
5272 {
5273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15577561 times.
15577561 if(script_knockback_clk!=0) //scripted knockback
5274 {
5275 sclk = 0;
5276 return 1; //scripted knockback ran
5277 }
5278
5/6
✓ Branch 0 taken 101710 times.
✓ Branch 1 taken 15475851 times.
✓ Branch 2 taken 7832 times.
✓ Branch 3 taken 93878 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7832 times.
15577561 if(sclk==0 || (hp<=0 && !immortal))
5279 15483683 return 0;
5280
5281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93878 times.
93878 if(knockbackflags & FLAG_NOSLIDE)
5282 {
5283 sclk = 0;
5284 if(!OFFGRID_ENEMY)
5285 {
5286 //Fix to grid
5287 do_fix(x, 16, true);
5288 do_fix(y, 16, true);
5289 }
5290 return 0;
5291 }
5292
8/10
✓ Branch 0 taken 9523 times.
✓ Branch 1 taken 84355 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9225 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7076 times.
✓ Branch 7 taken 2149 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
93878 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5293 {
5294 2149 sclk=0;
5295 2149 return 0;
5296 }
5297
5298 91729 --sclk;
5299
5300
5/5
✓ Branch 0 taken 1769 times.
✓ Branch 1 taken 10523 times.
✓ Branch 2 taken 12281 times.
✓ Branch 3 taken 31543 times.
✓ Branch 4 taken 35613 times.
91729 switch(sclk>>8)
5301 {
5302 case up:
5303 {
5304
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9433 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10516 times.
10523 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5305 {
5306 7 sclk=0;
5307 7 return 0;
5308 }
5309
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9426 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10516 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5310
5311 10341 break;
5312 }
5313 case down:
5314 {
5315
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12279 times.
12281 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5316 {
5317 2 sclk=0;
5318 2 return 0;
5319 }
5320
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11210 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12279 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5321
5322 12133 break;
5323 }
5324 case left:
5325 {
5326
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29189 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31530 times.
31543 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5327 {
5328 13 sclk=0;
5329 13 return 0;
5330 }
5331
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29176 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31530 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5332
5333 31292 break;
5334 }
5335 case right:
5336 {
5337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35613 times.
35613 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5338 {
5339 sclk=0;
5340 return 0;
5341 }
5342
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32325 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35613 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5343 35343 break;
5344 }
5345 }
5346
5347 90878 int32_t move = knockbackSpeed;
5348
2/2
✓ Branch 0 taken 86004 times.
✓ Branch 1 taken 90878 times.
176882 while(move>0)
5349 {
5350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90878 times.
90878 int32_t thismove = zc_min(8, move);
5351 90878 move -= thismove;
5352 90878 hitdir = (sclk>>8);
5353
5/5
✓ Branch 0 taken 1769 times.
✓ Branch 1 taken 10341 times.
✓ Branch 2 taken 12133 times.
✓ Branch 3 taken 31292 times.
✓ Branch 4 taken 35343 times.
90878 switch(sclk>>8)
5354 {
5355 case up:
5356 10341 y-=thismove;
5357 10341 break;
5358
5359 case down:
5360 12133 y+=thismove;
5361 12133 break;
5362
5363 case left:
5364 31292 x-=thismove;
5365 31292 break;
5366
5367 case right:
5368 35343 x+=thismove;
5369 35343 break;
5370 }
5371
2/2
✓ Branch 0 taken 86004 times.
✓ Branch 1 taken 4874 times.
90878 if(!canmove(sclk>>8,(zfix)0,0,true))
5372 {
5373
3/3
✓ Branch 0 taken 1972 times.
✓ Branch 1 taken 2898 times.
✓ Branch 2 taken 4 times.
4874 switch(sclk>>8)
5374 {
5375 case up:
5376 case down:
5377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1972 times.
1972 if(y < 0)
5378 y = 0;
5379
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1647 times.
1972 else if((int32_t(y)&15) > 7)
5380 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5381 else
5382 1647 y = TRUNCATE_TILE(int32_t(y));
5383
5384 1972 break;
5385
5386 case left:
5387 case right:
5388
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2894 times.
2898 if(x < 0)
5389 4 x = 0;
5390
2/2
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 2065 times.
2894 else if((int32_t(x)&15) > 7)
5391 829 x = TRUNCATE_TILE(int32_t(x)) + 16;
5392 else
5393 2065 x = TRUNCATE_TILE(int32_t(x));
5394
5395 2898 break;
5396 }
5397
5398 4874 sclk=0;
5399 4874 clk3=0;
5400 4874 break;
5401 }
5402 }
5403
5404
2/2
✓ Branch 0 taken 83542 times.
✓ Branch 1 taken 7336 times.
90878 if((sclk&255)==0)
5405 {
5406 //hitdir = -1;
5407 7336 sclk=0;
5408 7336 }
5409 90878 return 2;
5410 15577561 }
5411
5412 bool enemy::can_slide()
5413 {
5414 if(sclk==0 || (hp<=0 && !immortal))
5415 return false;
5416
5417 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5418 {
5419 return false;
5420 }
5421
5422 return true;
5423 }
5424
5425 bool enemy::fslide()
5426 {
5427 if(sclk==0 || (hp<=0 && !immortal))
5428 return false;
5429
5430 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5431 {
5432 sclk=0;
5433 return false;
5434 }
5435
5436 --sclk;
5437
5438 switch(sclk>>8)
5439 {
5440 case up:
5441 if(y<=16)
5442 {
5443 sclk=0;
5444 return false;
5445 }
5446
5447 break;
5448
5449 case down:
5450 if(y>=world_h-16)
5451 {
5452 sclk=0;
5453 return false;
5454 }
5455
5456 break;
5457
5458 case left:
5459 if(x<=16)
5460 {
5461 sclk=0;
5462 return false;
5463 }
5464
5465 break;
5466
5467 case right:
5468 if(x>=world_w-16)
5469 {
5470 sclk=0;
5471 return false;
5472 }
5473
5474 break;
5475 }
5476 hitdir = (sclk>>8);
5477 switch(sclk>>8)
5478 {
5479 case up:
5480 y-=4;
5481 break;
5482
5483 case down:
5484 y+=4;
5485 break;
5486
5487 case left:
5488 x-=4;
5489 break;
5490
5491 case right:
5492 x+=4;
5493 break;
5494 }
5495
5496 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5497 {
5498 switch(sclk>>8)
5499 {
5500 case up:
5501 case down:
5502 if((int32_t(y)&15) > 7)
5503 y = TRUNCATE_TILE(int32_t(y)) + 16;
5504 else
5505 y = TRUNCATE_TILE(int32_t(y));
5506
5507 break;
5508
5509 case left:
5510 case right:
5511 if((int32_t(x)&15) > 7)
5512 x = TRUNCATE_TILE(int32_t(x)) + 16;
5513 else
5514 x = TRUNCATE_TILE(int32_t(x));
5515
5516 break;
5517 }
5518
5519 sclk=0;
5520 clk3=0;
5521 }
5522
5523 if((sclk&255)==0)
5524 sclk=0;
5525
5526 return true;
5527 }
5528
5529 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5530 {
5531 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5532 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5533 bool ret = sprite::knockback(time, dir, speed);
5534 if(ret) sclk = 0; //kill engine knockback if interrupted
5535 //! Perhaps also set hitdir here, if needed for timing? -Z
5536 return ret;
5537 }
5538
5539 37840437 bool enemy::runKnockback()
5540 {
5541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37840437 times.
37840437 if((script_knockback_clk&0xFF)==0)
5542 {
5543 37840437 script_knockback_clk = 0;
5544 37840437 return false;
5545 }
5546 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5547 {
5548 return false;
5549 }
5550 int32_t move = script_knockback_speed;
5551 int32_t kb_dir = script_knockback_clk>>8;
5552 --script_knockback_clk;
5553
5554 while(move>0)
5555 {
5556 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5557 move -= thismove;
5558 hitdir = kb_dir;
5559 switch(kb_dir)
5560 {
5561 case r_up:
5562 case l_up:
5563 case up:
5564 y-=thismove;
5565 break;
5566
5567 case r_down:
5568 case l_down:
5569 case down:
5570 y+=thismove;
5571 break;
5572 }
5573 switch(kb_dir)
5574 {
5575 case l_up:
5576 case l_down:
5577 case left:
5578 x-=thismove;
5579 break;
5580
5581 case r_up:
5582 case r_down:
5583 case right:
5584 x+=thismove;
5585 break;
5586 }
5587 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5588 {
5589 if(!canmove(kb_dir,(zfix)0,0,true))
5590 {
5591 script_knockback_clk=0;
5592 clk3=0;
5593 //Fix to grid
5594 switch(kb_dir)
5595 {
5596 case up:
5597 case down:
5598 break;
5599 default:
5600 if(x < 0)
5601 x = 0;
5602 else if((int32_t(x)&15) > 7)
5603 x = TRUNCATE_TILE(int32_t(x)) + 16;
5604 else
5605 x = TRUNCATE_TILE(int32_t(x));
5606 break;
5607 }
5608 switch(kb_dir)
5609 {
5610 case left:
5611 case right:
5612 break;
5613 default:
5614 if(y < 0)
5615 y = 0;
5616 else if((int32_t(y)&15) > 7)
5617 y = TRUNCATE_TILE(int32_t(y)) + 16;
5618 else
5619 y = TRUNCATE_TILE(int32_t(y));
5620 break;
5621 }
5622 break;
5623 }
5624 }
5625 else
5626 {
5627 if(!scr_canplace(x,y,0,true))
5628 {
5629 script_knockback_clk=0;
5630 clk3=0;
5631 //Fix to grid
5632 if (OFFGRID_ENEMY)
5633 {
5634 switch(kb_dir)
5635 {
5636 case up:
5637 case down:
5638 break;
5639 default:
5640 if(x < 0)
5641 x = 0;
5642 else if((int32_t(x)&7) > 3)
5643 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5644 else
5645 x = TRUNCATE_HALF_TILE(int32_t(x));
5646 break;
5647 }
5648 switch(kb_dir)
5649 {
5650 case left:
5651 case right:
5652 break;
5653 default:
5654 if(y < 0)
5655 y = 0;
5656 else if((int32_t(y)&7) > 3)
5657 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5658 else
5659 y = TRUNCATE_HALF_TILE(int32_t(y));
5660 break;
5661 }
5662 }
5663 else
5664 {
5665 switch(kb_dir)
5666 {
5667 case up:
5668 case down:
5669 break;
5670 default:
5671 if(x < 0)
5672 x = 0;
5673 else if((int32_t(x)&15) > 7)
5674 x = TRUNCATE_TILE(int32_t(x)) + 16;
5675 else
5676 x = TRUNCATE_TILE(int32_t(x));
5677 break;
5678 }
5679 switch(kb_dir)
5680 {
5681 case left:
5682 case right:
5683 break;
5684 default:
5685 if(y < 0)
5686 y = 0;
5687 else if((int32_t(y)&15) > 7)
5688 y = TRUNCATE_TILE(int32_t(y)) + 16;
5689 else
5690 y = TRUNCATE_TILE(int32_t(y));
5691 break;
5692 }
5693 }
5694 break;
5695 }
5696
5697 }
5698 }
5699 return true;
5700 37840437 }
5701 // changes enemy's direction, checking restrictions
5702 // rate: 0 = no random changes, 16 = always random change
5703 // homing: 0 = none, 256 = always
5704 // grumble 0 = none, 4 = strongest appetite
5705 518087 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5706 {
5707 518087 int32_t ndir=-1;
5708
5709
4/4
✓ Branch 0 taken 109652 times.
✓ Branch 1 taken 408435 times.
✓ Branch 2 taken 37767 times.
✓ Branch 3 taken 71885 times.
518087 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5710 {
5711 71885 int32_t i = Lwpns.idFirst(wBait);
5712
1/2
✓ Branch 0 taken 71885 times.
✗ Branch 1 not taken.
71885 if(i >= 0) //idfirst returns -1 if it can't find any
5713 {
5714 weapon *w = (weapon*)Lwpns.spr(i);
5715 if (get_qr(qr_FIND_CLOSEST_BAIT))
5716 {
5717 int32_t currentrange;
5718 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5719 else currentrange = -1;
5720 int curid = i;
5721 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5722 for(; i<Lwpns.Count(); ++i)
5723 {
5724 weapon *lw = (weapon*)Lwpns.spr(i);
5725 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5726 {
5727 currentrange = distance(x, y, lw->x, lw->y);
5728 curid = i;
5729 }
5730 }
5731 i = curid;
5732 if (currentrange == -1) i = -1;
5733 }
5734 else
5735 {
5736 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5737 }
5738 if (i >= 0)
5739 {
5740 int32_t bx = Lwpns.spr(i)->x;
5741 int32_t by = Lwpns.spr(i)->y;
5742
5743 if(abs(int32_t(y)-by)>14)
5744 {
5745 ndir = (by<y) ? up : down;
5746 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5747 if(canmove(ndir,special,false))
5748 {
5749 dir=ndir;
5750 return;
5751 }
5752 }
5753
5754 ndir = (bx<x) ? left : right;
5755 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5756 if(canmove(ndir,special,false))
5757 {
5758 dir=ndir;
5759 return;
5760 }
5761 }
5762 }
5763 71885 }
5764
5765
2/2
✓ Branch 0 taken 350669 times.
✓ Branch 1 taken 167418 times.
518087 if((zc_oldrand()&255)<abs(newhoming))
5766 {
5767 167418 ndir = lined_up(8,false);
5768
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167418 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167418 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5769
4/4
✓ Branch 0 taken 45175 times.
✓ Branch 1 taken 122243 times.
✓ Branch 2 taken 5694 times.
✓ Branch 3 taken 39481 times.
167418 if(ndir>=0 && canmove(ndir,special,false))
5770 {
5771 39481 dir=ndir;
5772 39481 return;
5773 }
5774 127937 }
5775
5776 478606 int32_t i=0;
5777
5778
2/2
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 1169471 times.
1172739 for(; i<32; i++)
5779 {
5780 1169471 int32_t r=zc_oldrand();
5781
5782
2/2
✓ Branch 0 taken 342109 times.
✓ Branch 1 taken 827362 times.
1169471 if((r&15)<newrate)
5783 342109 ndir=(r>>4)&3;
5784 else
5785 827362 ndir=dir;
5786
5787
2/2
✓ Branch 0 taken 694133 times.
✓ Branch 1 taken 475338 times.
1169471 if(canmove(ndir,special,false))
5788 475338 break;
5789 694133 }
5790
5791
2/2
✓ Branch 0 taken 475338 times.
✓ Branch 1 taken 3268 times.
479352 if(i==32)
5792 {
5793
2/2
✓ Branch 0 taken 8680 times.
✓ Branch 1 taken 746 times.
9426 for(ndir=0; ndir<4; ndir++)
5794 {
5795
2/2
✓ Branch 0 taken 6158 times.
✓ Branch 1 taken 2522 times.
8680 if(canmove(ndir,special,false))
5796 2522 goto ok;
5797 6158 }
5798
5799
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 686 times.
746 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5800 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5801 746 }
5802
5803 ok:
5804 478606 dir = ndir;
5805 518087 }
5806
5807 2677 void enemy::newdir()
5808 {
5809 2677 newdir(4,0,spw_none);
5810 2677 }
5811
5812 zfix enemy::distance_left()
5813 {
5814 int32_t a2=x.getInt();
5815 int32_t b2=y.getInt();
5816
5817 switch(dir)
5818 {
5819 case up:
5820 return (zfix)(b2&0xF);
5821
5822 case down:
5823 return (zfix)(16-(b2&0xF));
5824
5825 case left:
5826 return (zfix)(a2&0xF);
5827
5828 case right:
5829 return (zfix)(16-(a2&0xF));
5830 }
5831
5832 return (zfix)0;
5833 }
5834
5835 // keeps walking around
5836 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5837 {
5838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5839 return;
5840
5841
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5842 8261 return;
5843
5844
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5845 {
5846 26115 fix_coords(true);
5847 26115 newdir(newrate,newhoming,special);
5848
5849
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5850 clk3=0;
5851 else
5852 26115 clk3=int32_t(16.0/step);
5853 26115 }
5854
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5855 {
5856 45 dir^=1;
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5858 else clk3=32767;
5859 45 }
5860
5861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5862 383173 move(step);
5863 391434 }
5864
5865 void enemy::constant_walk()
5866 {
5867 constant_walk(4,0,spw_none);
5868 }
5869
5870 35069 int32_t enemy::pos(int32_t newx,int32_t newy)
5871 {
5872 35069 return (newy<<8)+newx;
5873 }
5874
5875 // for variable step rates
5876 471795 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5877 {
5878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 471795 times.
471795 if(slide())
5879 return;
5880
5881
10/14
✓ Branch 0 taken 471795 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 471795 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 463170 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 453896 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 416391 times.
✓ Branch 9 taken 37505 times.
✓ Branch 10 taken 416391 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 416391 times.
✗ Branch 13 not taken.
471795 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5882 55404 return;
5883
5884 416391 zfix dx = (zfix)0;
5885 416391 zfix dy = (zfix)0;
5886
5887
5/9
✓ Branch 0 taken 92954 times.
✓ Branch 1 taken 96775 times.
✓ Branch 2 taken 111315 times.
✓ Branch 3 taken 113516 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
416391 switch(dir)
5888 {
5889 case 8:
5890 case up:
5891 92954 dy-=step;
5892 92954 break;
5893
5894 case 12:
5895 case down:
5896 96775 dy+=step;
5897 96775 break;
5898
5899 case 14:
5900 case left:
5901 111315 dx-=step;
5902 111315 break;
5903
5904 case 10:
5905 case right:
5906 113516 dx+=step;
5907 113516 break;
5908
5909 case 15:
5910 case l_up:
5911 dx-=step;
5912 dy-=step;
5913 break;
5914
5915 case 9:
5916 case r_up:
5917 dx+=step;
5918 dy-=step;
5919 break;
5920
5921 case 13:
5922 case l_down:
5923 dx-=step;
5924 dy+=step;
5925 break;
5926
5927 case 11:
5928 case r_down:
5929 dx+=step;
5930 dy+=step;
5931 break;
5932 }
5933
5934
8/8
✓ Branch 0 taken 202705 times.
✓ Branch 1 taken 213686 times.
✓ Branch 2 taken 22679 times.
✓ Branch 3 taken 180026 times.
✓ Branch 4 taken 11503 times.
✓ Branch 5 taken 11176 times.
✓ Branch 6 taken 404001 times.
✓ Branch 7 taken 12390 times.
416391 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5935 404888 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5936 {
5937 12390 fix_coords();
5938 12390 newdir(newrate,newhoming,special);
5939 12390 clk3=pos(x,y);
5940 12390 }
5941
5942 416391 move(step);
5943 471795 }
5944
5945 // pauses for a while after it makes a complete move (to a new square)
5946 12274888 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5947 {
5948
4/4
✓ Branch 0 taken 79514 times.
✓ Branch 1 taken 12195374 times.
✓ Branch 2 taken 66787 times.
✓ Branch 3 taken 12727 times.
12274888 if(sclk && clk2)
5949 {
5950 12727 clk3=0;
5951 12727 }
5952
5953
11/14
✓ Branch 0 taken 12202238 times.
✓ Branch 1 taken 72650 times.
✓ Branch 2 taken 12202238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12202238 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11736647 times.
✓ Branch 7 taken 465591 times.
✓ Branch 8 taken 11598898 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11594362 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11594362 times.
12274888 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5954 {
5955 680526 return;
5956 }
5957
5958
2/2
✓ Branch 0 taken 2124917 times.
✓ Branch 1 taken 9469445 times.
11594362 if(clk2>0)
5959 {
5960 2124917 --clk2;
5961 2124917 return;
5962 }
5963
5964
2/2
✓ Branch 0 taken 408680 times.
✓ Branch 1 taken 9060765 times.
9469445 if(clk3<=0)
5965 {
5966 408680 fix_coords(true);
5967 408680 newdir(newrate,newhoming,special);
5968 408680 clk3=int32_t(16.0/step);
5969
2/2
✓ Branch 0 taken 408483 times.
✓ Branch 1 taken 197 times.
408680 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408680 times.
408680 if(clk2<0)
5971 {
5972 clk2=0;
5973 }
5974
2/2
✓ Branch 0 taken 54582 times.
✓ Branch 1 taken 354098 times.
408680 else if((zc_oldrand()&15)<newhrate)
5975 {
5976 54582 clk2=haltcnt;
5977 54582 return;
5978 }
5979 354098 }
5980
2/2
✓ Branch 0 taken 9057640 times.
✓ Branch 1 taken 3125 times.
9060765 else if(scored)
5981 {
5982 3125 dir^=1;
5983
5984
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3120 times.
3125 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5985 5 else clk3=32767;
5986 3125 }
5987
5988
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9337924 times.
9414863 if (step != 0) --clk3;
5989 9414863 move(step);
5990 12274888 }
5991
5992 // 8-directional movement, aligns to 8 pixels
5993 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5994 {
5995 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5996 return;
5997
5998 if(clk3<=0)
5999 {
6000 newdir_8(newrate,newhoming,special);
6001 clk3=int32_t(8.0/step);
6002 if (step == 0) clk3 = 32767;
6003 }
6004
6005 if (step != 0) --clk3;
6006 move(step);
6007 }
6008 // 8-directional movement, aligns to 8 pixels
6009 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6010 {
6011
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6012 return;
6013
6014
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6015 {
6016 16235 newdir_8(newrate,newhoming,special);
6017 16235 clk3=int32_t(8.0/step);
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6019 16235 }
6020
6021
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6022 242393 move(step);
6023 242393 }
6024
6025 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6026 {
6027 if(clk<0 || dying || stunclk || watch || frozenclock)
6028 return;
6029
6030 if(!canmove(dir,step,special,false))
6031 clk3=0;
6032
6033 if(clk2>0)
6034 {
6035 --clk2;
6036 return;
6037 }
6038
6039 if(clk3<=0)
6040 {
6041 newdir_8(newrate,newhoming,special);
6042 clk3=newclk;
6043
6044 if(clk2<0)
6045 {
6046 clk2=0;
6047 }
6048 else if((zc_oldrand()&15)<newhrate)
6049 {
6050 newdir_8(newrate,newhoming,special);
6051 clk2=haltcnt;
6052 return;
6053 }
6054 }
6055
6056 --clk3;
6057 move(step);
6058 }
6059
6060 // 8-directional movement, no alignment
6061 4699691 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6062 {
6063
9/12
✓ Branch 0 taken 4491260 times.
✓ Branch 1 taken 208431 times.
✓ Branch 2 taken 4491260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4464639 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4453592 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4453592 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4453592 times.
4699691 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6064 246099 return;
6065
6066
2/2
✓ Branch 0 taken 4423209 times.
✓ Branch 1 taken 30383 times.
4453592 if(!canmove(dir,step,special,false))
6067 30383 clk3=0;
6068
6069
2/2
✓ Branch 0 taken 3898197 times.
✓ Branch 1 taken 555395 times.
4453592 if(clk3<=0)
6070 {
6071 555395 newdir_8(newrate,newhoming,special);
6072 555395 clk3=newclk;
6073 555395 }
6074
6075 4453592 --clk3;
6076 4453592 move(step);
6077 4699691 }
6078
6079 // same as above but with variable enemy size
6080 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6081 {
6082
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6083 1247 return;
6084
6085
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6086 1334 clk3=0;
6087
6088
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6089 {
6090 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6091 6475 clk3=newclk;
6092 6475 }
6093
6094 93316 --clk3;
6095 93316 move(step);
6096 94563 }
6097
6098 // the variable speed floater movement
6099 // ms is max speed
6100 // ss is step speed
6101 // s is step count
6102 // p is pause count
6103 // g is graduality :)
6104 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6105 4001923 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6106 {
6107 4001923 ++clk2;
6108 4001923 byte over_pit = overpit(this);
6109
6110
4/4
✓ Branch 0 taken 1114626 times.
✓ Branch 1 taken 2887297 times.
✓ Branch 2 taken 1114359 times.
✓ Branch 3 taken 267 times.
4001923 if(dmisc1 && over_pit) p = 0;
6111
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56345 times.
✓ Branch 2 taken 1576794 times.
✓ Branch 3 taken 2236283 times.
✓ Branch 4 taken 132501 times.
4001923 switch(movestatus)
6112 {
6113 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6114 //! if the conditions prevent it, we jump back to case 2.
6115 case 0: // paused
6116
2/2
✓ Branch 0 taken 54896 times.
✓ Branch 1 taken 1449 times.
56345 if(clk2>=p)
6117 {
6118 1449 movestatus=1;
6119 1449 clk2=0;
6120 1449 }
6121
6122 56345 break;
6123
6124 case 1: // speeding up
6125
1/2
✓ Branch 0 taken 1576794 times.
✗ Branch 1 not taken.
1576794 if (s >= 0)
6126 {
6127
2/2
✓ Branch 0 taken 1565536 times.
✓ Branch 1 taken 11258 times.
1576794 if(clk2<g*s)
6128 {
6129
2/2
✓ Branch 0 taken 1464542 times.
✓ Branch 1 taken 100994 times.
1565536 if(!((clk2-1)%g))
6130 100994 step+=ss;
6131 1565536 }
6132 else
6133 {
6134 11258 movestatus=2;
6135 11258 clk2=0;
6136 }
6137 1576794 }
6138 else
6139 {
6140 if(step < ms)
6141 {
6142 if(!((clk2-1)%g))
6143 {
6144 step+=ss;
6145 if (step >= ms) step = ms;
6146 }
6147 }
6148 else
6149 {
6150 step = ms;
6151 movestatus=2;
6152 clk2=0;
6153 }
6154 }
6155
6156 1576794 break;
6157
6158 case 2: // normal
6159 2236283 step=ms;
6160
6161
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2236283 times.
✓ Branch 2 taken 478961 times.
✓ Branch 3 taken 1757322 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1757322 times.
✓ Branch 6 taken 1755077 times.
✓ Branch 7 taken 2245 times.
2236283 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6162 {
6163
1/2
✓ Branch 0 taken 2245 times.
✗ Branch 1 not taken.
2245 if (s >= 0) step=ss*s;
6164 else step=ms;
6165 2245 movestatus=3;
6166 2245 clk2=0;
6167 2245 }
6168
6169 2236283 break;
6170
6171 case 3: // slowing down
6172
1/2
✓ Branch 0 taken 132501 times.
✗ Branch 1 not taken.
132501 if (s >= 0)
6173 {
6174
2/2
✓ Branch 0 taken 130823 times.
✓ Branch 1 taken 1678 times.
132501 if(clk2<=g*s)
6175 {
6176 { //don't slow down over pits
6177
6178
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 130556 times.
130823 if(over_pit)
6179 {
6180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6181 {
6182 step=ms;
6183 }
6184 267 }
6185 else //can slow down
6186 {
6187
4/4
✓ Branch 0 taken 8054 times.
✓ Branch 1 taken 122502 times.
✓ Branch 2 taken 7686 times.
✓ Branch 3 taken 368 times.
130556 if(!(clk2%g) && !dmisc1)
6188 7686 step-=ss;
6189 }
6190 }
6191
6192
6193 130823 }
6194 else
6195 {
6196 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6197 //this doesn't help keese, as they have a z of 0.
6198 //they always nee to run this check.
6199 {
6200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1678 if(over_pit &&!dmisc1)
6201 {
6202 --clk2; //if over a pit, don't land, and revert clock change
6203 }
6204 else //can land safely
6205 {
6206 1678 movestatus=0;
6207
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1678 if(dmisc1&&!over_pit)
6208 1115 step=0;
6209 1678 clk2=0;
6210 }
6211 }
6212
6213 }
6214 132501 }
6215 else
6216 {
6217 if(step > 0)
6218 {
6219 if(over_pit)
6220 {
6221 if(dmisc1)
6222 {
6223 step=ms;
6224 }
6225 }
6226 else //can slow down
6227 {
6228 if(!(clk2%g))
6229 step-=ss;
6230 }
6231 }
6232 else
6233 {
6234 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6235 //this doesn't help keese, as they have a z of 0.
6236 //they always nee to run this check.
6237 if(over_pit)
6238 {
6239 step+=ss; //if over a pit, don't land, and revert clock change
6240 }
6241 else //can land safely
6242 {
6243 movestatus=0;
6244 step=0;
6245 clk2=0;
6246 }
6247 }
6248 }
6249
6250 132501 break;
6251 }
6252
6253
2/2
✓ Branch 0 taken 2245296 times.
✓ Branch 1 taken 1756627 times.
4001923 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6254 4001923 }
6255
6256 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6257 {
6258 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6259 }
6260
6261 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6262 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6263 925457 int32_t enemy::lined_up(int32_t range, bool dir8)
6264 {
6265 925457 int32_t lx = Hero.getX();
6266 925457 int32_t ly = Hero.getY();
6267
6268
2/2
✓ Branch 0 taken 38693 times.
✓ Branch 1 taken 886764 times.
925457 if(abs(lx-int32_t(x))<=range)
6269 {
6270
2/2
✓ Branch 0 taken 16253 times.
✓ Branch 1 taken 22440 times.
38693 if(ly<y)
6271 {
6272 16253 return up;
6273 }
6274
6275 22440 return down;
6276 }
6277
6278
2/2
✓ Branch 0 taken 56132 times.
✓ Branch 1 taken 830632 times.
886764 if(abs(ly-int32_t(y))<=range)
6279 {
6280
2/2
✓ Branch 0 taken 30181 times.
✓ Branch 1 taken 25951 times.
56132 if(lx<x)
6281 {
6282 30181 return left;
6283 }
6284
6285 25951 return right;
6286 }
6287
6288
2/2
✓ Branch 0 taken 159470 times.
✓ Branch 1 taken 671162 times.
830632 if(dir8)
6289 {
6290
2/2
✓ Branch 0 taken 253453 times.
✓ Branch 1 taken 417709 times.
671162 if(abs(lx-x)-abs(ly-y)<=range)
6291 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6292 {
6293
2/2
✓ Branch 0 taken 105927 times.
✓ Branch 1 taken 147526 times.
253453 if(ly<y)
6294 {
6295
2/2
✓ Branch 0 taken 56636 times.
✓ Branch 1 taken 49291 times.
105927 if(lx<x)
6296 {
6297 56636 return l_up;
6298 }
6299 else
6300 {
6301 49291 return r_up;
6302 }
6303 }
6304 else
6305 {
6306
2/2
✓ Branch 0 taken 76579 times.
✓ Branch 1 taken 70947 times.
147526 if(lx<x)
6307 {
6308 70947 return l_down;
6309 }
6310 else
6311 {
6312 76579 return r_down;
6313 }
6314 }
6315 }
6316 417709 }
6317
6318 577179 return -1;
6319 925457 }
6320
6321 // returns true if Hero is within 'range' pixels of the enemy
6322 27679 bool enemy::HeroInRange(int32_t range)
6323 {
6324 27679 int32_t lx = Hero.getX();
6325 27679 int32_t ly = Hero.getY();
6326
2/2
✓ Branch 0 taken 22622 times.
✓ Branch 1 taken 5057 times.
27679 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6327 }
6328
6329 // place the enemy in line with Hero (red wizzrobes)
6330 4897 void enemy::place_on_axis(bool floater, bool solid_ok)
6331 {
6332
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4310 times.
✓ Branch 2 taken 4353 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3766 times.
4897 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6333
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4458 times.
✓ Branch 2 taken 4107 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3668 times.
4897 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6334 4897 int32_t pos2=zc_oldrand()%23;
6335 4897 int32_t tried=0;
6336 4897 bool last_resort,placed=false;
6337
6338
6339 4897 do
6340 {
6341
2/2
✓ Branch 0 taken 4458 times.
✓ Branch 1 taken 3127 times.
7585 if(pos2<14)
6342 {
6343 4458 x=(pos2<<4)+16;
6344 4458 y=ly;
6345 4458 }
6346 else
6347 {
6348 3127 x=lx;
6349 3127 y=((pos2-14)<<4)+16;
6350 }
6351
6352 // Don't commit to a last resort if position is out of bounds.
6353
6/6
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 338 times.
✓ Branch 2 taken 6935 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6678 times.
7585 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6354
6355
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3678 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1287 times.
7585 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6356 {
6357 // Red Wizzrobes should be able to appear on water, but not other
6358 // solid combos; however, they could appear on solid combos in 2.10,
6359 // and some quests depend on that.
6360
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6199 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4897 times.
8540 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6361 8540 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6362 4897 placed=true;
6363 8540 }
6364
6365
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4535 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7223 if(!placed && tried>=22 && last_resort)
6366 {
6367 placed=true;
6368 }
6369
6370 7223 ++tried;
6371 7223 pos2=(pos2+3)%23;
6372
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4535 times.
7223 }
6373 7223 while(!placed);
6374
6375
2/2
✓ Branch 0 taken 2727 times.
✓ Branch 1 taken 1808 times.
4535 if(y==ly)
6376 2727 dir=(x<lx)?right:left;
6377 else
6378 1808 dir=(y<ly)?down:up;
6379
6380 4535 clk2=tried;
6381 4535 }
6382
6383 20225702 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6384 {
6385 20225702 int32_t t = o_tile;
6386 20225702 int32_t b = o_tile;
6387
6388 // Darknuts, but also Wizzrobes and Wallmasters
6389
3/4
✓ Branch 0 taken 8375470 times.
✓ Branch 1 taken 10814787 times.
✓ Branch 2 taken 1035445 times.
✗ Branch 3 not taken.
20225702 switch(family)
6390 {
6391 case eeWALK:
6392
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10309380 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10814787 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6393 {
6394 367468 tile=s_tile;
6395 367468 t=s_tile;
6396 367468 b=s_tile;
6397 367468 }
6398
6399 10814787 break;
6400
6401 case eeTRAP:
6402
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 841879 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1035445 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6403 {
6404 193566 tile=s_tile;
6405 193566 t=s_tile;
6406 193566 b=s_tile;
6407 193566 }
6408
6409 1035445 break;
6410
6411 case eeSPINTILE:
6412 if(misc>=96 && do_animation)
6413 {
6414 tile=o_tile+frames*ndir;
6415 t=tile;
6416 }
6417
6418 break;
6419 }
6420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20225702 times.
20225702 if ( do_animation )
6421 {
6422
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20028660 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19761529 times.
20225702 if(ndir!=0) switch(frames)
6423 {
6424 case 2:
6425 267131 tiledir_small(dir,ndir==4);
6426 267131 break;
6427
6428 case 3:
6429 tiledir_three(dir);
6430 break;
6431
6432 case 4:
6433 19761529 tiledir(dir,ndir==4);
6434 19761529 break;
6435 20028660 }
6436
6437
2/2
✓ Branch 0 taken 10814787 times.
✓ Branch 1 taken 9410915 times.
20225702 if(family==eeWALK)
6438
6/6
✓ Branch 0 taken 10754952 times.
✓ Branch 1 taken 59835 times.
✓ Branch 2 taken 8164658 times.
✓ Branch 3 taken 2650129 times.
✓ Branch 4 taken 2634685 times.
✓ Branch 5 taken 15444 times.
10814787 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6439 else
6440 9410915 tile+=f4;
6441 20225702 }
6442 20225702 return b;
6443 }
6444
6445 void enemy::tiledir_three(int32_t ndir)
6446 {
6447 if ( !do_animation ) return;
6448 flip=0;
6449
6450 switch(ndir)
6451 {
6452 case right:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case left:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case down:
6461 tile+=3;
6462 [[fallthrough]];
6463
6464 case up:
6465 break;
6466 }
6467 }
6468
6469 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6470 {
6471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6472 267131 flip=0;
6473
6474
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6475 {
6476 case 8:
6477 case up:
6478 53829 break;
6479
6480 case 12:
6481 case down:
6482 54679 tile+=2;
6483 54679 break;
6484
6485 case 14:
6486 case left:
6487 67727 tile+=4;
6488 67727 break;
6489
6490 case 10:
6491 case right:
6492 71182 tile+=6;
6493 71182 break;
6494
6495 case 9:
6496 case r_up:
6497
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6498 5706 break;
6499
6500 tile+=10;
6501 break;
6502
6503 case 11:
6504 case r_down:
6505
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6506 5154 tile+=2;
6507 else
6508 tile+=14;
6509
6510 5154 break;
6511
6512 case 13:
6513 case l_down:
6514
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6515 4872 tile+=2;
6516 else
6517 tile+=12;
6518
6519 4872 break;
6520
6521 case 15:
6522 case l_up:
6523
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6524 3982 break;
6525
6526 tile+=8;
6527 break;
6528
6529 default:
6530 //dir=(zc_oldrand()*100)%8;
6531 //tiledir_small(dir);
6532 // flip=zc_oldrand()&3;
6533 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6534 break;
6535 }
6536 267131 }
6537
6538 23065088 void enemy::tiledir(int32_t ndir, bool fourdir)
6539 {
6540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23065088 times.
23065088 if ( !do_animation ) return;
6541 23065088 flip=0;
6542
6543
9/9
✓ Branch 0 taken 4482305 times.
✓ Branch 1 taken 4143416 times.
✓ Branch 2 taken 5408686 times.
✓ Branch 3 taken 5161273 times.
✓ Branch 4 taken 829917 times.
✓ Branch 5 taken 1022447 times.
✓ Branch 6 taken 1101787 times.
✓ Branch 7 taken 849582 times.
✓ Branch 8 taken 65675 times.
23065088 switch(ndir)
6544 {
6545 case 8:
6546 case up:
6547 4482305 break;
6548
6549 case 12:
6550 case down:
6551 4143416 tile+=4;
6552 4143416 break;
6553
6554 case 14:
6555 case left:
6556 5408686 tile+=8;
6557 5408686 break;
6558
6559 case 10:
6560 case right:
6561 5161273 tile+=12;
6562 5161273 break;
6563
6564 case 9:
6565 case r_up:
6566
2/2
✓ Branch 0 taken 88962 times.
✓ Branch 1 taken 740955 times.
829917 if(fourdir)
6567 88962 break;
6568 else
6569 740955 tile+=24;
6570
6571 740955 break;
6572
6573 case 11:
6574 case r_down:
6575
2/2
✓ Branch 0 taken 102546 times.
✓ Branch 1 taken 919901 times.
1022447 if(fourdir)
6576 102546 tile+=4;
6577 else
6578 919901 tile+=32;
6579
6580 1022447 break;
6581
6582 case 13:
6583 case l_down:
6584
2/2
✓ Branch 0 taken 105677 times.
✓ Branch 1 taken 996110 times.
1101787 if(fourdir)
6585 105677 tile+=4;
6586 else
6587 996110 tile+=28;
6588
6589 1101787 break;
6590
6591 case 15:
6592 case l_up:
6593
2/2
✓ Branch 0 taken 82743 times.
✓ Branch 1 taken 766839 times.
849582 if(fourdir)
6594 82743 break;
6595 else
6596 766839 tile+=20;
6597
6598 766839 break;
6599
6600 default:
6601 //dir=(zc_oldrand()*100)%8;
6602 //tiledir(dir);
6603 // flip=zc_oldrand()&3;
6604 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6605 65675 break;
6606 }
6607 23065088 }
6608
6609 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6610 {
6611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6612 3868 flip=0;
6613
6614
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6615 {
6616 case 8:
6617 case up:
6618 297 break;
6619
6620 case 12:
6621 case down:
6622 tile+=8;
6623 break;
6624
6625 case 14:
6626 case left:
6627 195 tile+=40;
6628 195 break;
6629
6630 case 10:
6631 case right:
6632 179 tile+=48;
6633 179 break;
6634
6635 case 9:
6636 case r_up:
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6638 break;
6639
6640 306 tile+=88;
6641 306 break;
6642
6643 case 11:
6644 case r_down:
6645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6646 tile+=8;
6647 else
6648 1235 tile+=128;
6649
6650 1235 break;
6651
6652 case 13:
6653 case l_down:
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6655 tile+=8;
6656 else
6657 1324 tile+=120;
6658
6659 1324 break;
6660
6661 case 15:
6662 case l_up:
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6664 break;
6665
6666 332 tile+=80;
6667 332 break;
6668
6669 default:
6670 //dir=(zc_oldrand()*100)%8;
6671 //tiledir_big(dir);
6672 // flip=zc_oldrand()&3;
6673 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6674 break;
6675 }
6676 3868 }
6677
6678 39994693 void enemy::update_enemy_frame()
6679 {
6680
4/4
✓ Branch 0 taken 39992318 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 39992311 times.
39994693 if(fallclk||drownclk) return;
6681
1/2
✓ Branch 0 taken 39992311 times.
✗ Branch 1 not taken.
39992311 if (!do_animation)
6682 return;
6683
6684
4/4
✓ Branch 0 taken 1549487 times.
✓ Branch 1 taken 38442824 times.
✓ Branch 2 taken 1547480 times.
✓ Branch 3 taken 2007 times.
39992311 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6685
6686
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
39992311 if(get_qr(qr_ANONE_NOANIM)
6687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39992311 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39992311 && anim == aNONE && family != eeGUY)
6688 return;
6689
2/2
✓ Branch 0 taken 371174 times.
✓ Branch 1 taken 39621137 times.
39992311 int32_t newfrate = zc_max(frate,4);
6690 39992311 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6691 39992311 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6692
2/2
✓ Branch 0 taken 29996017 times.
✓ Branch 1 taken 9996294 times.
39992311 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6693 39992311 tile = o_tile;
6694 39992311 int32_t basetile = o_tile;
6695 39992311 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6696 39992311 bool ignore_extend = false;
6697
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 207738 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 359653 times.
✓ Branch 8 taken 831598 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5070163 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1510096 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 691972 times.
✓ Branch 22 taken 1694091 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4105118 times.
✓ Branch 27 taken 7478173 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1817567 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 6981462 times.
✓ Branch 37 taken 741838 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
39992311 switch(anim)
6698 {
6699
6700 case aDONGO:
6701 {
6702 69324 int32_t fr = stunclk>0 ? 16 : 8;
6703
6704
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6705 {
6706 // bloated
6707
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6708 {
6709 case up:
6710 960 tile+=9;
6711 960 flip=0;
6712 960 xofs=0;
6713 960 dummy_int[1]=0; //no additional tiles
6714 960 break;
6715
6716 case down:
6717 960 tile+=7;
6718 960 flip=0;
6719 960 xofs=0;
6720 960 dummy_int[1]=0; //no additional tiles
6721 960 break;
6722
6723 case left:
6724 1664 flip=1;
6725 1664 tile+=4;
6726 1664 xofs=16;
6727 1664 dummy_int[1]=1; //second tile is next tile
6728 1664 break;
6729
6730 case right:
6731 896 flip=0;
6732 896 tile+=5;
6733 896 xofs=16;
6734 896 dummy_int[1]=-1; //second tile is previous tile
6735 896 break;
6736 }
6737 4480 }
6738
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6739 {
6740 // normal
6741
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6742 {
6743 case up:
6744 13652 tile+=8;
6745 13652 flip=(clk&fr)?1:0;
6746 13652 xofs=0;
6747 13652 dummy_int[1]=0; //no additional tiles
6748 13652 break;
6749
6750 case down:
6751 15374 tile+=6;
6752 15374 flip=(clk&fr)?1:0;
6753 15374 xofs=0;
6754 15374 dummy_int[1]=0; //no additional tiles
6755 15374 break;
6756
6757 case left:
6758 19615 flip=1;
6759 19615 tile+=(clk&fr)?2:0;
6760 19615 xofs=16;
6761 19615 dummy_int[1]=1; //second tile is next tile
6762 19615 break;
6763
6764 case right:
6765 15086 flip=0;
6766 15086 tile+=(clk&fr)?3:1;
6767 15086 xofs=16;
6768 15086 dummy_int[1]=-1; //second tile is next tile
6769 15086 break;
6770 }
6771 63727 }
6772 }
6773 69324 break;
6774
6775 case aNEWDONGO:
6776 {
6777 53456 int32_t fr4=0;
6778
6779
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6780 {
6781 // bloated
6782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6783 {
6784 2752 fr4=3;
6785 2752 }
6786
6787
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6788 {
6789 2107 fr4=2;
6790 2107 }
6791
6792
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6793 {
6794 1419 fr4=1;
6795 1419 }
6796
6797
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6798 {
6799 731 fr4=0;
6800 731 }
6801
6802
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6803 {
6804 case up:
6805 256 xofs=0;
6806 256 tile+=8+fr4;
6807 256 dummy_int[1]=0; //no additional tiles
6808 256 break;
6809
6810 case down:
6811 576 xofs=0;
6812 576 tile+=12+fr4;
6813 576 dummy_int[1]=0; //no additional tiles
6814 576 break;
6815
6816 case left:
6817 704 tile+=29+(2*fr4);
6818 704 xofs=16;
6819 704 dummy_int[1]=-1; //second tile is previous tile
6820 704 break;
6821
6822 case right:
6823 1216 tile+=49+(2*fr4);
6824 1216 xofs=16;
6825 1216 dummy_int[1]=-1; //second tile is previous tile
6826 1216 break;
6827 }
6828 2752 }
6829
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6830 {
6831 // normal
6832
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6833 {
6834 case up:
6835 9234 xofs=0;
6836 9234 tile+=((clk&12)>>2);
6837 9234 dummy_int[1]=0; //no additional tiles
6838 9234 break;
6839
6840 case down:
6841 9871 xofs=0;
6842 9871 tile+=4+((clk&12)>>2);
6843 9871 dummy_int[1]=0; //no additional tiles
6844 9871 break;
6845
6846 case left:
6847 15025 tile+=21+((clk&12)>>1);
6848 15025 xofs=16;
6849 15025 dummy_int[1]=-1; //second tile is previous tile
6850 15025 break;
6851
6852 case right:
6853 15676 flip=0;
6854 15676 tile+=41+((clk&12)>>1);
6855 15676 xofs=16;
6856 15676 dummy_int[1]=-1; //second tile is previous tile
6857 15676 break;
6858 }
6859 49806 }
6860 }
6861 53456 break;
6862
6863 case aDONGOBS:
6864 {
6865 38833 int32_t fr4=0;
6866
6867
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6868 {
6869 // bloated
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6871 {
6872 2688 fr4=3;
6873 2688 }
6874
6875
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6876 {
6877 2058 fr4=2;
6878 2058 }
6879
6880
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6881 {
6882 1386 fr4=1;
6883 1386 }
6884
6885
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6886 {
6887 714 fr4=0;
6888 714 }
6889
6890
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6891 {
6892 case up:
6893 256 tile+=28+fr4;
6894 256 yofs+=8;
6895 256 dummy_int[1]=-20; //second tile change
6896 256 dummy_int[2]=0; //new xofs change
6897 256 dummy_int[3]=-16; //new xofs change
6898 256 break;
6899
6900 case down:
6901 384 tile+=12+fr4;
6902 384 yofs-=8;
6903 384 dummy_int[1]=20; //second tile change
6904 384 dummy_int[2]=0; //new xofs change
6905 384 dummy_int[3]=16; //new xofs change
6906 384 break;
6907
6908 case left:
6909 1024 tile+=49+(2*fr4);
6910 1024 xofs+=8;
6911 1024 dummy_int[1]=-1; //second tile change
6912 1024 dummy_int[2]=-16; //new xofs change
6913 1024 dummy_int[3]=0; //new xofs change
6914 1024 break;
6915
6916 case right:
6917 1024 tile+=69+(2*fr4);
6918 1024 xofs+=8;
6919 1024 dummy_int[1]=-1; //second tile change
6920 1024 dummy_int[2]=-16; //new xofs change
6921 1024 dummy_int[3]=0; //new xofs change
6922 1024 break;
6923 }
6924 2688 }
6925
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6926 {
6927 // normal
6928
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6929 {
6930 case up:
6931 7136 tile+=20+((clk&24)>>3);
6932 7136 yofs+=8;
6933 7136 dummy_int[1]=-20; //second tile change
6934 7136 dummy_int[2]=0; //new xofs change
6935 7136 dummy_int[3]=-16; //new xofs change
6936 7136 break;
6937
6938 case down:
6939 6672 tile+=4+((clk&24)>>3);
6940 6672 yofs-=8;
6941 6672 dummy_int[1]=20; //second tile change
6942 6672 dummy_int[2]=0; //new xofs change
6943 6672 dummy_int[3]=16; //new xofs change
6944 6672 break;
6945
6946 case left:
6947 11075 xofs=-8;
6948 11075 tile+=40+((clk&24)>>2);
6949 11075 dummy_int[1]=1; //second tile change
6950 11075 dummy_int[2]=16; //new xofs change
6951 11075 dummy_int[3]=0; //new xofs change
6952 11075 break;
6953
6954 case right:
6955 10601 tile+=60+((clk&24)>>2);
6956 10601 xofs=-8;
6957 10601 dummy_int[1]=1; //second tile change
6958 10601 dummy_int[2]=16; //new xofs change
6959 10601 dummy_int[3]=0; //new xofs change
6960 10601 break;
6961 }
6962 35484 }
6963 }
6964 38833 break;
6965
6966 case aWIZZ:
6967 {
6968 // if(d->misc1)
6969
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6970 {
6971
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6972 {
6973 91127 ++tile;
6974 91127 }
6975 182184 }
6976 else
6977 {
6978
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6979 {
6980 136489 ++tile;
6981 136489 }
6982 }
6983
6984
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6985 {
6986 case 9:
6987 case 15:
6988 case up:
6989 76094 tile+=2;
6990 76094 break;
6991
6992 case down:
6993 76591 break;
6994
6995 case 13:
6996 case left:
6997 157108 flip=1;
6998 157108 break;
6999
7000 default:
7001 145581 flip=0;
7002 145581 break;
7003 }
7004 }
7005 455374 break;
7006
7007 case aNEWWIZZ:
7008 {
7009 1510096 tiledir(dir,true);
7010
7011 // if(d->misc1) //walking wizzrobe
7012
2/2
✓ Branch 0 taken 727031 times.
✓ Branch 1 taken 783065 times.
1510096 if(dmisc1) //walking wizzrobe
7013 {
7014
2/2
✓ Branch 0 taken 365559 times.
✓ Branch 1 taken 361472 times.
727031 if(clk&8)
7015 {
7016 361472 tile+=2;
7017 361472 }
7018
7019
2/2
✓ Branch 0 taken 364397 times.
✓ Branch 1 taken 362634 times.
727031 if(clk&4)
7020 {
7021 362634 tile+=1;
7022 362634 }
7023
7024
2/4
✓ Branch 0 taken 727031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 727031 times.
727031 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7025 {
7026
2/2
✓ Branch 0 taken 649098 times.
✓ Branch 1 taken 77933 times.
727031 if(dummy_int[1]>0)
7027 {
7028 77933 tile+=40;
7029 77933 }
7030 727031 }
7031 727031 }
7032 else
7033 {
7034
4/4
✓ Branch 0 taken 715956 times.
✓ Branch 1 taken 67109 times.
✓ Branch 2 taken 168735 times.
✓ Branch 3 taken 547221 times.
783065 if(dummy_bool[1]||dummy_bool[2])
7035 {
7036 235844 tile+=20;
7037
7038
2/2
✓ Branch 0 taken 67100 times.
✓ Branch 1 taken 168744 times.
235844 if(dummy_bool[2])
7039 {
7040 168744 tile+=20;
7041 168744 }
7042 235844 }
7043
7044 783065 tile+=((frame>>1)&3);
7045 }
7046 }
7047 1510096 break;
7048
7049 case a3FRM:
7050 {
7051
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7052 }
7053 197042 break;
7054
7055 case a3FRM4DIR:
7056 {
7057 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7058 }
7059 break;
7060
7061 case aVIRE:
7062 {
7063
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7064 {
7065 29292 tile+=2;
7066 29292 }
7067
7068 128880 tile+=fx;
7069 }
7070 128880 break;
7071
7072 case aROPE:
7073 {
7074 220021 tile+=(1-fx);
7075 220021 flip = dir==left ? 1:0;
7076 }
7077 220021 break;
7078
7079 case aZORA:
7080 {
7081 int32_t dl;
7082
7083
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7084 {
7085 46739 dl=clk+5;
7086 46739 goto waves2;
7087 }
7088
7089
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7090
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7091 else
7092 {
7093 92458 dl=clk-36-66;
7094 waves2:
7095 139197 tile=((dl/11)&1)+s_tile;
7096 139197 basetile = s_tile;
7097 }
7098 }
7099 221637 break;
7100
7101 case aNEWZORA:
7102 {
7103 691972 f4=(clk/16)%4;
7104
7105 691972 tiledir(dir,true);
7106 int32_t dl;
7107
7108
4/4
✓ Branch 0 taken 488971 times.
✓ Branch 1 taken 203001 times.
✓ Branch 2 taken 250764 times.
✓ Branch 3 taken 238207 times.
691972 if((clk>35)&&(clk<36+67)) //surfaced
7109 {
7110
4/4
✓ Branch 0 taken 203646 times.
✓ Branch 1 taken 34561 times.
✓ Branch 2 taken 29404 times.
✓ Branch 3 taken 174242 times.
238207 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7111 {
7112 174242 tile+=80;
7113 174242 } //mouth closed
7114 else
7115 {
7116 63965 tile+=40;
7117 }
7118
7119 238207 tile+=f4;
7120 238207 }
7121 else
7122 {
7123
2/2
✓ Branch 0 taken 203001 times.
✓ Branch 1 taken 250764 times.
453765 if(clk<36)
7124 {
7125 203001 dl=clk+5;
7126 203001 }
7127 else
7128 {
7129 250764 dl=clk-36-66;
7130 }
7131
7132 453765 tile+=((dl/5)&3);
7133 }
7134 }
7135 691972 break;
7136
7137 case a4FRM4EYE:
7138 case a2FRM4EYE:
7139 case a4FRM8EYE:
7140 case a4FRM8EYEB: //big version
7141 case a4FRM4EYEB:
7142 {
7143 831598 tilerows = 2;
7144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831598 times.
831598 int fakex = x + 8*(zc_max(1,txsz)-1);
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831598 times.
831598 int fakey = y + 8*(zc_max(1,tysz)-1);
7146 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7147 831598 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7148 831598 int32_t lookat=zc_oldrand()&15;
7149
7150
4/4
✓ Branch 0 taken 271889 times.
✓ Branch 1 taken 559709 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210572 times.
831598 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7151 {
7152 210572 lookat=l_down;
7153 210572 }
7154
4/4
✓ Branch 0 taken 285957 times.
✓ Branch 1 taken 335069 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 224640 times.
621026 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7155 {
7156 224640 lookat=down;
7157 224640 }
7158
4/4
✓ Branch 0 taken 168424 times.
✓ Branch 1 taken 227962 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 107107 times.
396386 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7159 {
7160 107107 lookat=r_down;
7161 107107 }
7162
4/4
✓ Branch 0 taken 130756 times.
✓ Branch 1 taken 158523 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 69439 times.
289279 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7163 {
7164 69439 lookat=right;
7165 69439 }
7166
4/4
✓ Branch 0 taken 96346 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35029 times.
219840 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7167 {
7168 35029 lookat=r_up;
7169 35029 }
7170
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7171 {
7172 25436 lookat=up;
7173 25436 }
7174
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7175 {
7176 36803 lookat=l_up;
7177 36803 }
7178 else
7179 {
7180 122572 lookat=left;
7181 }
7182
7183 831598 int32_t dir2 = dir;
7184 831598 dir = lookat;
7185
3/6
✓ Branch 0 taken 831598 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 831598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 831598 times.
831598 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7186 else
7187 {
7188 tiledir_big(dir,(anim == a4FRM4EYEB));
7189 tile+=2*f4;
7190 ignore_extend = true;
7191 }
7192 831598 dir = dir2;
7193 }
7194 831598 break;
7195
7196 case aFLIP:
7197 {
7198 1694091 flip = f2&1;
7199 }
7200 1694091 break;
7201
7202 case a2FRM:
7203 {
7204 1134909 tile += (1-f2);
7205 }
7206 1134909 break;
7207
7208 case a2FRMB:
7209 {
7210 tile+= 2*(1-f2);
7211 ignore_extend = true;
7212 }
7213 break;
7214
7215 case a2FRM4DIR:
7216 {
7217 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7218 }
7219 267131 break;
7220
7221 case a4FRM4DIRF:
7222 {
7223 4105118 basetile = n_frame_n_dir(4,4,f4);
7224
7225
2/2
✓ Branch 0 taken 2713861 times.
✓ Branch 1 taken 1391257 times.
4105118 if(clk2>0) //stopped to fire
7226 {
7227 1391257 tile+=20;
7228
7229
2/2
✓ Branch 0 taken 692166 times.
✓ Branch 1 taken 699091 times.
1391257 if(clk2<17) //firing
7230 {
7231 699091 tile+=20;
7232 699091 }
7233 1391257 }
7234 }
7235 4105118 break;
7236
7237 case a4FRM4DIR:
7238 {
7239 7478173 basetile = n_frame_n_dir(4,4,f4);
7240 }
7241 7478173 break;
7242
7243 case a4FRM8DIRF:
7244 {
7245 tilerows = 2;
7246 basetile = n_frame_n_dir(4,8,f4);
7247
7248 if(clk2>0) //stopped to fire
7249 {
7250 tile+=40;
7251
7252 if(clk2<17) //firing
7253 {
7254 tile+=40;
7255 }
7256 }
7257 }
7258 break;
7259
7260 case a4FRM8DIRB:
7261 case a4FRM8DIRFB:
7262 {
7263 3868 tilerows = 2;
7264 3868 tiledir_big(dir,false);
7265 3868 tile+=2*f4;
7266
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7267 {
7268 tile+=80;
7269
7270 if(clk2<17) //firing
7271 {
7272 tile+=80;
7273 }
7274 }
7275 3868 ignore_extend = true;
7276 }
7277 3868 break;
7278
7279 case a4FRM4DIRB:
7280 case a4FRM4DIRFB:
7281 {
7282 tilerows = 2;
7283 tiledir_big(dir,true);
7284 tile+=2*f4;
7285 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7286 {
7287 tile+=40;
7288
7289 if(clk2<17) //firing
7290 {
7291 tile+=40;
7292 }
7293 }
7294 ignore_extend = true;
7295 }
7296 break;
7297
7298 case aOCTO:
7299 {
7300
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7301 {
7302 case up:
7303 122459 flip = 2;
7304 122459 break;
7305
7306 case down:
7307 133448 flip = 0;
7308 133448 break;
7309
7310 case left:
7311 165651 flip = 0;
7312 165651 tile += 2;
7313 165651 break;
7314
7315 case right:
7316 157227 flip = 1;
7317 157227 tile += 2;
7318 157227 break;
7319 }
7320
7321 582937 tile+=f2;
7322 }
7323 582937 break;
7324
7325 case aWALK:
7326 {
7327
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7328 {
7329 case up:
7330 248704 tile+=3;
7331 248704 flip = f2;
7332 248704 break;
7333
7334 case down:
7335 267165 tile+=2;
7336 267165 flip = f2;
7337 267165 break;
7338
7339 case left:
7340 331694 flip=1;
7341 331694 tile += f2;
7342 331694 break;
7343
7344 case right:
7345 325802 flip=0;
7346 325802 tile += f2;
7347 325802 break;
7348 }
7349 }
7350 1178979 break;
7351
7352 case aDWALK:
7353 {
7354
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7355 {
7356 tile=s_tile;
7357 basetile = s_tile;
7358 }
7359
7360
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7361 {
7362 case up:
7363 177728 tile+=2;
7364 177728 flip=f2;
7365 177728 break;
7366
7367 case down:
7368 185581 flip=0;
7369 185581 tile+=(1-f2);
7370 185581 break;
7371
7372 case left:
7373 260885 flip=1;
7374 260885 tile+=(3+f2);
7375 260885 break;
7376
7377 case right:
7378 255982 flip=0;
7379 255982 tile+=(3+f2);
7380 255982 break;
7381 }
7382 }
7383 880176 break;
7384
7385 case aTEK:
7386 {
7387
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7388 {
7389 79120 tile += f2;
7390 79120 }
7391
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7392 {
7393 66827 ++tile;
7394 66827 }
7395 }
7396 219096 break;
7397
7398 case aNEWTEK:
7399 {
7400
2/2
✓ Branch 0 taken 475160 times.
✓ Branch 1 taken 1342407 times.
1817567 if(step<0) //up
7401 {
7402
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235326 times.
✓ Branch 2 taken 239834 times.
475160 switch(clk3)
7403 {
7404 case left:
7405 235326 flip=0;
7406 235326 tile+=20;
7407 235326 break;
7408
7409 case right:
7410 239834 flip=0;
7411 239834 tile+=24;
7412 239834 break;
7413 }
7414 475160 }
7415
2/2
✓ Branch 0 taken 54741 times.
✓ Branch 1 taken 1287666 times.
1342407 else if(step==0)
7416 {
7417
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40561 times.
✓ Branch 2 taken 14180 times.
54741 switch(clk3)
7418 {
7419 case left:
7420 40561 flip=0;
7421 40561 tile+=8;
7422 40561 break;
7423
7424 case right:
7425 14180 flip=0;
7426 14180 tile+=12;
7427 14180 break;
7428 }
7429 54741 } //down
7430 else
7431 {
7432
3/3
✓ Branch 0 taken 109101 times.
✓ Branch 1 taken 592915 times.
✓ Branch 2 taken 585650 times.
1287666 switch(clk3)
7433 {
7434 case left:
7435 592915 flip=0;
7436 592915 tile+=28;
7437 592915 break;
7438
7439 case right:
7440 585650 flip=0;
7441 585650 tile+=32;
7442 585650 break;
7443 }
7444 }
7445
7446
2/2
✓ Branch 0 taken 1238371 times.
✓ Branch 1 taken 579196 times.
1817567 if(misc==0)
7447 {
7448 579196 tile+=f4;
7449 579196 }
7450
2/2
✓ Branch 0 taken 581909 times.
✓ Branch 1 taken 656462 times.
1238371 else if(misc!=1)
7451 {
7452 656462 tile+=2;
7453 656462 }
7454 }
7455 1817567 break;
7456
7457 case aARMOS:
7458 {
7459
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7460 {
7461 5401 tile += fx;
7462
7463
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7464 1197 tile += 2;
7465 5401 }
7466 }
7467 8628 break;
7468
7469 case aARMOS4:
7470 {
7471
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29013 times.
✓ Branch 2 taken 92158 times.
✓ Branch 3 taken 43250 times.
✓ Branch 4 taken 42867 times.
207738 switch(dir)
7472 {
7473 case up:
7474 29013 flip=0;
7475 29013 break;
7476
7477 case down:
7478 92158 flip=0;
7479 92158 tile+=4;
7480 92158 break;
7481
7482 case left:
7483 43250 flip=0;
7484 43250 tile+=8;
7485 43250 break;
7486
7487 case right:
7488 42867 flip=0;
7489 42867 tile+=12;
7490 42867 break;
7491 }
7492
7493
2/2
✓ Branch 0 taken 62775 times.
✓ Branch 1 taken 144963 times.
207738 if(!fading)
7494 {
7495 144963 tile+=f4;
7496 144963 }
7497 }
7498 207738 break;
7499
7500 case aGHINI:
7501 {
7502
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7503 {
7504 case 8:
7505 case 9:
7506 case up:
7507 28037 ++tile;
7508 28037 flip=0;
7509 28037 break;
7510
7511 case 15:
7512 452 ++tile;
7513 452 flip=1;
7514 452 break;
7515
7516 case 10:
7517 case 11:
7518 case right:
7519 32092 flip=1;
7520 32092 break;
7521
7522 default:
7523 72763 flip=0;
7524 72763 break;
7525 }
7526 }
7527 133344 break;
7528
7529 case a2FRMPOS:
7530 {
7531 1755010 tile+=posframe;
7532 }
7533 1755010 break;
7534
7535 case a4FRMPOS4DIR:
7536 {
7537 363745 basetile = n_frame_n_dir(4,4,0);
7538 // tile+=f2;
7539 363745 tile+=posframe;
7540 }
7541 363745 break;
7542
7543 case a4FRMPOS4DIRF:
7544 {
7545 1433 basetile = n_frame_n_dir(4,4,0);
7546
7547
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7548 {
7549 197 tile+=20;
7550
7551
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7552 {
7553 64 tile+=20;
7554 64 }
7555 197 }
7556
7557 // tile+=f2;
7558 1433 tile+=posframe;
7559 }
7560 1433 break;
7561
7562 case a4FRMPOS8DIR:
7563 {
7564 6981462 tilerows = 2;
7565 6981462 int32_t n = tile;
7566 6981462 basetile = n_frame_n_dir(4,8,0);
7567 // tile+=f2;
7568 6981462 tile+=posframe;
7569 }
7570 6981462 break;
7571
7572 case a4FRMPOS8DIRF:
7573 {
7574 tilerows = 2;
7575 basetile = n_frame_n_dir(4,8,0);
7576
7577 if(clk2>0) //stopped to fire
7578 {
7579 tile+=40;
7580
7581 if(clk2<17) //firing
7582 {
7583 tile+=40;
7584 }
7585 }
7586
7587 tile+=posframe;
7588 }
7589 break;
7590
7591 case aNEWLEV:
7592 {
7593 741838 tiledir(dir,true);
7594
7595
4/5
✓ Branch 0 taken 256718 times.
✓ Branch 1 taken 114596 times.
✓ Branch 2 taken 48592 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 321932 times.
741838 switch(misc)
7596 {
7597 case -1:
7598 case 0:
7599 256718 return;
7600
7601 case 1:
7602
7603 // case 5: cs = d->misc2; break;
7604 case 5:
7605 114596 cs = dmisc2;
7606 114596 break;
7607
7608 case 2:
7609 case 4:
7610 48592 tile += 20;
7611 48592 break;
7612
7613 case 3:
7614 321932 tile += 40;
7615 321932 break;
7616 }
7617
7618 485120 tile+=f4;
7619 }
7620 485120 break;
7621
7622 case aLEV:
7623 {
7624 276997 f4 = ((clk/5)&1);
7625
7626
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7627 {
7628 case -1:
7629 case 0:
7630 127945 return;
7631
7632 case 1:
7633
7634 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7635 case 5:
7636 33336 tile += (f2) ? 1 : 0;
7637 33336 cs = dmisc2;
7638 33336 break;
7639
7640 case 2:
7641 case 4:
7642 14658 tile += 2;
7643 14658 break;
7644
7645 case 3:
7646 101058 tile += (f4) ? 4 : 3;
7647 101058 break;
7648 }
7649 }
7650 149052 break;
7651
7652 case aWALLM:
7653 {
7654
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7655 {
7656 139764 tile += f2;
7657 139764 }
7658 }
7659 140514 break;
7660
7661 case aNEWWALLM:
7662 {
7663 359653 int32_t tempdir=0;
7664
7665
4/4
✓ Branch 0 taken 38619 times.
✓ Branch 1 taken 42442 times.
✓ Branch 2 taken 8358 times.
✓ Branch 3 taken 270234 times.
359653 switch(misc)
7666 {
7667 case 1:
7668 case 2:
7669 42442 tempdir=clk3;
7670 42442 break;
7671
7672 case 3:
7673 case 4:
7674 case 5:
7675 38619 tempdir=dir;
7676 38619 break;
7677
7678 case 6:
7679 case 7:
7680 8358 tempdir=clk3^1;
7681 8358 break;
7682 }
7683
7684 359653 tiledir(tempdir,true);
7685
7686
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 357745 times.
359653 if(!dummy_bool[1])
7687 {
7688 357745 tile+=f4;
7689 357745 }
7690 }
7691 359653 break;
7692
7693 case a4FRMNODIR:
7694 {
7695 171508 tile+=f4;
7696 }
7697 171508 break;
7698
7699 } // switch(d->anim)
7700
7701 // flashing
7702 // if(d->flags & guy_flashing)
7703
2/2
✓ Branch 0 taken 38862337 times.
✓ Branch 1 taken 745311 times.
39607648 if(flags & guy_flashing)
7704 {
7705 745311 cs = (frame&3) + 6;
7706 745311 }
7707
7708
2/2
✓ Branch 0 taken 39197160 times.
✓ Branch 1 taken 410488 times.
39607648 if(flags&guy_transparent)
7709 {
7710 410488 drawstyle=1;
7711 410488 }
7712
7713 39607648 int32_t change = tile-basetile;
7714
7715
3/6
✓ Branch 0 taken 2054943 times.
✓ Branch 1 taken 37552705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39607648 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7716 {
7717
2/2
✓ Branch 0 taken 1792915 times.
✓ Branch 1 taken 262028 times.
2054943 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7718 {
7719 1792915 tile=basetile+txsz*change;
7720 1792915 }
7721 else
7722 {
7723 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7724 }
7725 2054943 }
7726 else
7727 {
7728 37552705 tile=basetile+change;
7729 }
7730 39994693 }
7731
7732 80666 int32_t enemy::wpnsfx(int32_t wpn)
7733 {
7734
3/3
✓ Branch 0 taken 22362 times.
✓ Branch 1 taken 40745 times.
✓ Branch 2 taken 17559 times.
80666 switch (wpn)
7735 {
7736 case wScript1:
7737 case wScript2:
7738 case wScript3:
7739 case wScript4:
7740 case wScript5:
7741 case wScript6:
7742 case wScript7:
7743 case wScript8:
7744 case wScript9:
7745 case wScript10: //sure why not
7746 case ewFireTrail:
7747 case ewFlame:
7748 case ewFlame2Trail:
7749 case ewFlame2:
7750 case ewWind:
7751 case ewMagic:
7752 case ewIce:
7753 22362 return firesfx;
7754
7755 case ewRock:
7756 case ewFireball2:
7757 case ewFireball:
7758
2/2
✓ Branch 0 taken 5533 times.
✓ Branch 1 taken 35212 times.
40745 if (get_qr(qr_MORESOUNDS)) return firesfx;
7759 35212 break;
7760 }
7761
7762 52771 return 0;
7763 80666 }
7764
7765 76704053 int32_t enemy::run_script(int32_t mode)
7766 {
7767 void push_ri();
7768 void pop_ri();
7769
7770
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76703797 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76704053 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7771
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76703797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76703797 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7772 76703797 return RUNSCRIPT_OK;
7773 auto scrty = *get_scrtype();
7774 auto uid = getUID();
7775 if(!FFCore.doscript(scrty,uid))
7776 return RUNSCRIPT_OK;
7777 int32_t ret = RUNSCRIPT_OK;
7778 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7779 push_ri();
7780 switch(mode)
7781 {
7782 case MODE_NORMAL:
7783 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7784 break;
7785
7786 case MODE_WAITDRAW:
7787 if(waitdraw)
7788 {
7789 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7790 waitdraw = false;
7791 }
7792 break;
7793 }
7794 pop_ri();
7795 return ret;
7796 76704053 }
7797 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7798 {
7799 return al_map_rgba(255,0,0,opacity);
7800 }
7801
7802 // good guys, fires, fairy, and other non-enemies
7803 // based on enemy class b/c guys in dungeons act sort of like enemies
7804 // also easier to manage all the guys this way
7805 2188 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7806 2188 {
7807 2188 mainguy=mg;
7808 2188 canfreeze=false;
7809 2188 dir=down;
7810
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2188 times.
✓ Branch 2 taken 2188 times.
✗ Branch 3 not taken.
2188 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7811 2188 hxofs=2;
7812 2188 hzsz=8;
7813 2188 hit_width=12;
7814 2188 hit_height=17;
7815
7816
10/12
✓ Branch 0 taken 2188 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2188 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 762 times.
✓ Branch 5 taken 1426 times.
✓ Branch 6 taken 740 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 464 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2188 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7817 {
7818 1928 superman = 1;
7819 1928 hxofs=1000;
7820 1928 }
7821 2188 }
7822
7823 943159 bool guy::animate(int32_t index)
7824 {
7825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 943159 times.
943159 if(switch_hooked) return enemy::animate(index);
7826
6/6
✓ Branch 0 taken 542589 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8273 times.
✓ Branch 3 taken 534316 times.
✓ Branch 4 taken 7070 times.
✓ Branch 5 taken 1203 times.
943159 if(mainguy && clk==0 && misc==0)
7827 {
7828 1203 setupscreen();
7829 1203 misc = 1;
7830 1203 }
7831
7832
4/4
✓ Branch 0 taken 542589 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 542259 times.
✓ Branch 3 taken 330 times.
943159 if(mainguy && fadeclk==0)
7833 330 return true;
7834
7835 942829 hp=256; // good guys never die...
7836
7837
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 941907 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
942829 if(hclk && !clk2)
7838 {
7839 // but if they get hit...
7840 16 ++clk2; // only do this once
7841
7842
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7843 {
7844 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7845 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7846 7 }
7847 16 }
7848
7849 942829 return enemy::animate(index);
7850 943159 }
7851
7852 946931 void guy::draw(BITMAP *dest)
7853 {
7854 946931 update_enemy_frame();
7855
7856
6/6
✓ Branch 0 taken 546152 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 523241 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
946931 if(!mainguy || fadeclk<0 || fadeclk&1)
7857 935084 enemy::draw(dest);
7858 946931 }
7859
7860 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7861 760 {
7862 760 clk4=0;
7863
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7864 // Spawn type
7865
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7866 {
7867 clk=0;
7868 superman = 1;
7869 fading=fade_flicker;
7870 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7871 dir=down;
7872
7873 if(!canmove(down,(zfix)8,spw_none,false))
7874 clk3=int32_t(13.0/step);
7875 }
7876
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7877 {
7878 84 clk=0;
7879 84 }
7880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7881 760 }
7882
7883 167472 bool eFire::animate(int32_t index)
7884 {
7885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7886
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7887
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7888 {
7889
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7890 {
7891 1 clk4=0;
7892 1 superman=0;
7893 1 fading=0;
7894
7895
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7896 removearmos(x,y,ffcactivated);
7897
7898 1 clk2=0;
7899
7900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7901 {
7902 1 dir=0;
7903 1 y = TRUNCATE_TILE(y.getInt());
7904 1 }
7905
7906 1 return Dead(index);
7907 }
7908
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7909 removearmos(x,y,ffcactivated);
7910 1715 }
7911
7912 167471 return enemy::animate(index);
7913 167472 }
7914
7915 351659 void eFire::draw(BITMAP *dest)
7916 {
7917 351659 update_enemy_frame();
7918 351659 enemy::draw(dest);
7919 351659 }
7920
7921 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7922 {
7923 415 int32_t wpnId = w->id;
7924 415 int32_t wpnDir = w->dir;
7925
7926
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7927 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7928 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7929 {
7930 shield = false;
7931 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7932
7933 if(get_qr(qr_BRKNSHLDTILES))
7934 o_tile=s_tile;
7935 }
7936
7937 415 int32_t ret = enemy::takehit(w,realweap);
7938 415 return ret;
7939 }
7940
7941 void eFire::break_shield()
7942 {
7943 if(!shield)
7944 return;
7945
7946 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7947 shield=false;
7948
7949 if(get_qr(qr_BRKNSHLDTILES))
7950 o_tile=s_tile;
7951 }
7952
7953 void eFire::repair_shield()
7954 {
7955 if (shield)
7956 return;
7957
7958 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7959 return;
7960
7961 shield = true;
7962
7963 if (get_qr(qr_BRKNSHLDTILES))
7964 {
7965 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7966 else o_tile = d->tile;
7967 }
7968 }
7969
7970 7630 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7971 7630 {
7972 7630 clk4=0;
7973
4/8
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7630 times.
✗ Branch 7 not taken.
7630 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7974
7975 // Spawn type
7976
2/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7630 times.
7630 if(flags & guy_fade_flicker)
7977 {
7978 clk=0;
7979 superman = 1;
7980 fading=fade_flicker;
7981 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7982 dir=down;
7983
7984 if(!canmove(down,(zfix)8,spw_none,false))
7985 clk3=int32_t(13.0/step);
7986 }
7987
3/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1187 times.
7630 else if(flags & guy_fade_instant)
7988 {
7989 1187 clk=0;
7990 1187 }
7991
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7630 if (SIZEflags != 0) init_size_flags();;
7992 7630 }
7993
7994 1981512 bool eOther::animate(int32_t index)
7995 {
7996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981512 times.
1981512 if(switch_hooked) return enemy::animate(index);
7997
3/4
✓ Branch 0 taken 1979926 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979926 times.
1981512 if(fallclk||drownclk) return enemy::animate(index);
7998
2/2
✓ Branch 0 taken 1971390 times.
✓ Branch 1 taken 8536 times.
1979926 if(fading)
7999 {
8000
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
8001 {
8002 29 clk4=0;
8003 29 superman=0;
8004 29 fading=0;
8005
8006
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8007 removearmos(x,y,ffcactivated);
8008
8009 29 clk2=0;
8010
8011
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8012 {
8013 2 dir=0;
8014 2 y = TRUNCATE_TILE(y.getInt());
8015 2 }
8016
8017 29 return Dead(index);
8018 }
8019
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8020 removearmos(x,y,ffcactivated);
8021 8507 }
8022
8023 1979897 return enemy::animate(index);
8024 1981512 }
8025
8026 2087673 void eOther::draw(BITMAP *dest)
8027 {
8028 2087673 update_enemy_frame();
8029 2087673 enemy::draw(dest);
8030 2087673 }
8031
8032 14773 int32_t eOther::takehit(weapon *w, weapon* realweap)
8033 {
8034 14773 int32_t wpnId = w->id;
8035 14773 int32_t wpnDir = w->dir;
8036
8037
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14773 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8038 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8039 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8040 {
8041 shield = false;
8042 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8043
8044 if(get_qr(qr_BRKNSHLDTILES))
8045 o_tile=s_tile;
8046 }
8047
8048 14773 int32_t ret = enemy::takehit(w,realweap);
8049 14773 return ret;
8050 }
8051
8052 void eOther::break_shield()
8053 {
8054 if(!shield)
8055 return;
8056
8057 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8058 shield=false;
8059
8060 if(get_qr(qr_BRKNSHLDTILES))
8061 o_tile=s_tile;
8062 }
8063
8064 void eOther::repair_shield()
8065 {
8066 if (shield)
8067 return;
8068
8069 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8070 return;
8071
8072 shield = true;
8073
8074 if (get_qr(qr_BRKNSHLDTILES))
8075 {
8076 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8077 else o_tile = d->tile;
8078 }
8079 }
8080
8081 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8082 {
8083 clk4=0;
8084 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8085
8086 // Spawn type
8087 if(flags & guy_fade_flicker)
8088 {
8089 clk=0;
8090 superman = 1;
8091 fading=fade_flicker;
8092 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8093 dir=down;
8094
8095 if(!canmove(down,(zfix)8,spw_none,false))
8096 clk3=int32_t(13.0/step);
8097 }
8098 else if(flags & guy_fade_instant)
8099 {
8100 clk=0;
8101 }
8102 if (SIZEflags != 0) init_size_flags();;
8103 }
8104
8105 bool eScript::animate(int32_t index)
8106 {
8107 if(switch_hooked) return enemy::animate(index);
8108 if(fallclk||drownclk) return enemy::animate(index);
8109 if(fading)
8110 {
8111 if(++clk4 > 60)
8112 {
8113 clk4=0;
8114 superman=0;
8115 fading=0;
8116
8117 if(flags&guy_armos && z==0 && fakez==0)
8118 removearmos(x,y,ffcactivated);
8119
8120 clk2=0;
8121
8122 if(!canmove(down,(zfix)8,spw_none,false))
8123 {
8124 dir=0;
8125 y = TRUNCATE_TILE(y.getInt());
8126 }
8127
8128 return Dead(index);
8129 }
8130 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8131 removearmos(x,y,ffcactivated);
8132 }
8133
8134 return enemy::animate(index);
8135 }
8136
8137 void eScript::draw(BITMAP *dest)
8138 {
8139 update_enemy_frame();
8140 enemy::draw(dest);
8141 }
8142
8143 int32_t eScript::takehit(weapon *w, weapon* realweap)
8144 {
8145 int32_t wpnId = w->id;
8146 int32_t wpnDir = w->dir;
8147
8148 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8149 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8150 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8151 {
8152 shield = false;
8153 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8154
8155 if(get_qr(qr_BRKNSHLDTILES))
8156 o_tile=s_tile;
8157 }
8158
8159 int32_t ret = enemy::takehit(w,realweap);
8160 return ret;
8161 }
8162
8163 void eScript::break_shield()
8164 {
8165 if(!shield)
8166 return;
8167
8168 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8169 shield=false;
8170
8171 if(get_qr(qr_BRKNSHLDTILES))
8172 o_tile=s_tile;
8173 }
8174
8175 void eScript::repair_shield()
8176 {
8177 if (shield)
8178 return;
8179
8180 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8181 return;
8182
8183 shield = true;
8184
8185 if (get_qr(qr_BRKNSHLDTILES))
8186 {
8187 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8188 else o_tile = d->tile;
8189 }
8190 }
8191
8192
8193 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8194 {
8195 clk4=0;
8196 hyofs = -32768; //No hitbox initially.
8197 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8198
8199 // Spawn type
8200 if(flags & guy_fade_flicker)
8201 {
8202 clk=0;
8203 superman = 1;
8204 fading=fade_flicker;
8205 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8206 dir=down;
8207
8208 if(!canmove(down,(zfix)8,spw_none,false))
8209 clk3=int32_t(13.0/step);
8210 }
8211 else if(flags & guy_fade_instant)
8212 {
8213 clk=0;
8214 }
8215 if (SIZEflags != 0) init_size_flags();;
8216 }
8217
8218 bool eFriendly::animate(int32_t index)
8219 {
8220 if(switch_hooked) return enemy::animate(index);
8221 if(fallclk||drownclk) return enemy::animate(index);
8222 if(fading)
8223 {
8224 if(++clk4 > 60)
8225 {
8226 clk4=0;
8227 superman=0;
8228 fading=0;
8229
8230 if(flags&guy_armos && z==0 && fakez==0)
8231 removearmos(x,y,ffcactivated);
8232
8233 clk2=0;
8234
8235 if(!canmove(down,(zfix)8,spw_none,false))
8236 {
8237 dir=0;
8238 y = TRUNCATE_TILE(y.getInt());
8239 }
8240
8241 return Dead(index);
8242 }
8243 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8244 removearmos(x,y,ffcactivated);
8245 }
8246
8247 return enemy::animate(index);
8248 }
8249
8250 void eFriendly::draw(BITMAP *dest)
8251 {
8252 update_enemy_frame();
8253 enemy::draw(dest);
8254 }
8255
8256 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8257 {
8258 int32_t wpnId = w->id;
8259 int32_t wpnDir = w->dir;
8260
8261 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8262 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8263 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8264 {
8265 shield = false;
8266 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8267
8268 if(get_qr(qr_BRKNSHLDTILES))
8269 o_tile=s_tile;
8270 }
8271
8272 int32_t ret = enemy::takehit(w,realweap);
8273 return ret;
8274 }
8275
8276 void eFriendly::break_shield()
8277 {
8278 if(!shield)
8279 return;
8280
8281 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8282 shield=false;
8283
8284 if(get_qr(qr_BRKNSHLDTILES))
8285 o_tile=s_tile;
8286 }
8287
8288 void eFriendly::repair_shield()
8289 {
8290 if (shield)
8291 return;
8292
8293 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8294 return;
8295
8296 shield = true;
8297
8298 if (get_qr(qr_BRKNSHLDTILES))
8299 {
8300 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8301 else o_tile = d->tile;
8302 }
8303 }
8304
8305
8306 776804 void enemy::removearmos(int32_t ax,int32_t ay, std::optional<ffc_handle_t> ffcactive)
8307 {
8308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 776804 times.
776804 if (ffcactive)
8309 {
8310 removearmosffc(*ffcactive);
8311 return;
8312 }
8313
2/2
✓ Branch 0 taken 775789 times.
✓ Branch 1 taken 1015 times.
776804 if(did_armos)
8314 {
8315 775789 return;
8316 }
8317
8318 1015 auto rpos_handle = get_rpos_handle_for_world_xy(ax, ay, 0);
8319 1015 mapscr* scr = rpos_handle.scr;
8320 1015 ax = TRUNCATE_TILE(ax);
8321 1015 ay = TRUNCATE_TILE(ay);
8322
8323 1015 did_armos=true;
8324 1015 int32_t cd = rpos_handle.pos;
8325 1015 int32_t f = rpos_handle.sflag();
8326 1015 int32_t f2 = rpos_handle.cflag();
8327
8328
2/2
✓ Branch 0 taken 839 times.
✓ Branch 1 taken 176 times.
1015 if (rpos_handle.ctype() != cARMOS)
8329 {
8330 839 return;
8331 }
8332
8333 176 scr->data[cd] = scr->undercombo;
8334 176 scr->cset[cd] = scr->undercset;
8335 176 scr->sflag[cd] = 0;
8336
8337
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8338 {
8339 22 scr->data[cd] = scr->secretcombo[sSTAIRS];
8340 22 scr->cset[cd] = scr->secretcset[sSTAIRS];
8341 22 scr->sflag[cd]=scr->secretflag[sSTAIRS];
8342 22 sfx(scr->secretsfx);
8343 22 }
8344
8345
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8346 {
8347
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8348 {
8349 3 additem(ax,ay,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8350 3 sfx(scr->secretsfx);
8351 3 }
8352 3 }
8353
8354 176 putcombo(scrollbuf,ax,ay,scr->data[cd],scr->cset[cd]);
8355 776804 }
8356
8357 void enemy::removearmosffc(const ffc_handle_t& ffc_handle)
8358 {
8359 if(did_armos)
8360 {
8361 return;
8362 }
8363
8364 did_armos=true;
8365 ffcdata& ffc = *ffc_handle.ffc;
8366 mapscr* scr = ffc_handle.scr;
8367 auto& cmb = ffc_handle.combo();
8368 int32_t f2 = cmb.flag;
8369
8370 if(cmb.type!=cARMOS)
8371 {
8372 return;
8373 }
8374
8375 ffc_handle.set_data(scr->undercombo);
8376 ffc_handle.set_cset(scr->undercset);
8377
8378 if(f2 == mfARMOS_SECRET)
8379 {
8380 ffc_handle.set_data(scr->secretcombo[sSTAIRS]);
8381 ffc_handle.set_cset(scr->secretcset[sSTAIRS]);
8382 sfx(scr->secretsfx);
8383 }
8384
8385 if(f2 == mfARMOS_ITEM)
8386 {
8387 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8388 {
8389 additem(ffc.x,ffc.y,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8390 sfx(scr->secretsfx);
8391 }
8392 }
8393
8394 putcombo(scrollbuf,ffc.x,ffc.y,ffc_handle.data(),ffc.cset);
8395 }
8396
8397
8398 460 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8399 460 {
8400 460 fading=fade_flicker;
8401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
460 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8402 460 dir=12;
8403 460 movestatus=1;
8404
1/2
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
460 step=0;
8405 460 clk=0;
8406 460 clk4=0;
8407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
460 if (SIZEflags != 0) init_size_flags();;
8408 460 }
8409
8410 116796 bool eGhini::animate(int32_t index)
8411 {
8412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116796 times.
116796 if(switch_hooked) return enemy::animate(index);
8413
2/4
✓ Branch 0 taken 116796 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116796 times.
116796 if(fallclk||drownclk) return enemy::animate(index);
8414
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116746 times.
116796 if(dying)
8415 50 return Dead(index);
8416
8417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116746 times.
116746 if(dmisc1)
8418 {
8419
2/2
✓ Branch 0 taken 89584 times.
✓ Branch 1 taken 27162 times.
116746 if(misc)
8420 {
8421
2/2
✓ Branch 0 taken 34799 times.
✓ Branch 1 taken 54785 times.
89584 if(clk4>160)
8422 54785 misc=2;
8423
8424
2/2
✓ Branch 0 taken 34799 times.
✓ Branch 1 taken 54785 times.
89584 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8425 89584 removearmos(x,y,ffcactivated);
8426 89584 }
8427
2/2
✓ Branch 0 taken 26738 times.
✓ Branch 1 taken 424 times.
27162 else if(clk4>=60)
8428 {
8429 424 misc=1;
8430 424 clk3=32;
8431 424 fading=0;
8432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 424 times.
424 if (ffcactivated)
8433 {
8434 activation_counters_ffc[ffcactivated->id] = 0;
8435 removearmosffc(*ffcactivated);
8436 }
8437 else
8438 {
8439 424 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8440
1/2
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
424 if (rpos != rpos_t::None)
8441 {
8442 424 activation_counters[(int)rpos] = 0;
8443 424 removearmos(x,y);
8444 424 }
8445 }
8446 424 }
8447 116746 }
8448
8449 116746 clk4++;
8450
8451 116746 return enemy::animate(index);
8452 116796 }
8453
8454 238348 void eGhini::draw(BITMAP *dest)
8455 {
8456 238348 update_enemy_frame();
8457 238348 enemy::draw(dest);
8458 238348 }
8459
8460 2 void eGhini::kickbucket()
8461 {
8462 2 hp=-1000; // don't call death_sfx()
8463 2 }
8464
8465
2/4
✓ Branch 0 taken 5209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5209 times.
✗ Branch 3 not taken.
10418 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8466 5209 {
8467
1/2
✓ Branch 0 taken 5209 times.
✗ Branch 1 not taken.
5209 old_y=y;
8468 5209 dir=down;
8469 5209 misc=1;
8470 5209 clk=-15;
8471
8472
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2560 times.
5209 if(!BSZ)
8473
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8474
8475 // avoid divide by 0 errors
8476
1/2
✓ Branch 0 taken 5209 times.
✗ Branch 1 not taken.
5209 if(dmisc1 == 0)
8477 dmisc1 = 24;
8478
8479
1/2
✓ Branch 0 taken 5209 times.
✗ Branch 1 not taken.
5209 if(dmisc2 == 0)
8480 dmisc2 = 3;
8481
8482 //nets+760;
8483
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5209 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5209 if (SIZEflags != 0) init_size_flags();;
8484 5209 }
8485
8486 1435853 bool eTektite::animate(int32_t index)
8487 {
8488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1435853 times.
1435853 if(switch_hooked) return enemy::animate(index);
8489
4/4
✓ Branch 0 taken 1426907 times.
✓ Branch 1 taken 8946 times.
✓ Branch 2 taken 8946 times.
✓ Branch 3 taken 1424505 times.
1435853 if(fallclk||drownclk) return enemy::animate(index);
8490
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1397838 times.
1424505 if(dying)
8491 26667 return Dead(index);
8492
8493
2/2
✓ Branch 0 taken 1360756 times.
✓ Branch 1 taken 37082 times.
1397838 if(clk==0)
8494 {
8495 37082 removearmos(x,y,ffcactivated);
8496 37082 }
8497
8498
2/2
✓ Branch 0 taken 1056655 times.
✓ Branch 1 taken 341183 times.
1397838 if(get_qr(qr_ENEMIESZAXIS))
8499 {
8500 341183 y=floor_y;
8501 341183 }
8502
8503
9/10
✓ Branch 0 taken 1283047 times.
✓ Branch 1 taken 114791 times.
✓ Branch 2 taken 1269483 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1269483 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258307 times.
✓ Branch 8 taken 11960 times.
✓ Branch 9 taken 21878 times.
1397838 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8504 {
8505
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421349 times.
✓ Branch 2 taken 345019 times.
✓ Branch 3 taken 493557 times.
1280185 switch(misc)
8506 {
8507 case 0: // normal
8508
2/2
✓ Branch 0 taken 410120 times.
✓ Branch 1 taken 11229 times.
421349 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8509 {
8510 11229 misc=1;
8511 11229 clk2=32;
8512 11229 }
8513
8514 421349 break;
8515
8516 case 1: // waiting to pounce
8517
2/2
✓ Branch 0 taken 324391 times.
✓ Branch 1 taken 20628 times.
345019 if(--clk2<=0)
8518 {
8519 20628 int32_t r=zc_oldrand();
8520 20628 misc=2;
8521 20628 step=0-(zslongToFix(dstep*100)); // initial speed
8522 20628 clk3=(r&1)+2; // left or right
8523 20628 clk2start=clk2=(r&31)+10; // flight time
8524
8525
2/2
✓ Branch 0 taken 18205 times.
✓ Branch 1 taken 2423 times.
20628 if(y<32) clk2+=2; // make them come down from top of screen
8526
8527
2/2
✓ Branch 0 taken 15710 times.
✓ Branch 1 taken 4918 times.
20628 if(y>world_h-64) clk2-=2; // make them go back up
8528
8529 20628 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8530 20628 }
8531
8532 345019 break;
8533
8534 case 2: // in flight
8535 493557 move(step);
8536
8537
2/2
✓ Branch 0 taken 234243 times.
✓ Branch 1 taken 259314 times.
493557 if(step>0) //going down
8538 {
8539
2/2
✓ Branch 0 taken 631 times.
✓ Branch 1 taken 233612 times.
234243 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8540 {
8541 631 step=0-step;
8542 631 }
8543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233612 times.
233612 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8544 {
8545 step=0-step;
8546 }
8547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233612 times.
233612 else if(ispitfall(x+8,y+16))
8548 {
8549 step=0-step;
8550 }
8551
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233565 times.
233612 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8552 {
8553 47 step=0-step;
8554 47 }
8555
2/2
✓ Branch 0 taken 233554 times.
✓ Branch 1 taken 11 times.
233565 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8556 {
8557 11 step=0-step;
8558 11 }
8559 234243 }
8560
2/2
✓ Branch 0 taken 15158 times.
✓ Branch 1 taken 244156 times.
259314 else if(step<0)
8561 {
8562
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243718 times.
244156 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8563 {
8564 438 step=0-step;
8565 438 }
8566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243718 times.
243718 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8567 {
8568 step=0-step;
8569 }
8570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243718 times.
243718 else if(ispitfall(x+8,y))
8571 {
8572 step=0-step;
8573 }
8574
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243697 times.
243718 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8575 {
8576 21 step=0-step;
8577 21 }
8578
2/2
✓ Branch 0 taken 243678 times.
✓ Branch 1 taken 19 times.
243697 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8579 {
8580 19 step=0-step;
8581 19 }
8582 244156 }
8583
8584
2/2
✓ Branch 0 taken 244215 times.
✓ Branch 1 taken 249342 times.
493557 if(clk3==left)
8585 {
8586
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 243940 times.
244215 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8587 {
8588 275 clk3^=1;
8589 275 }
8590
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 243934 times.
243940 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8591 {
8592 6 clk3^=1;
8593 6 }
8594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243934 times.
243934 else if(ispitfall(x,y+8))
8595 {
8596 clk3^=1;
8597 }
8598
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 243904 times.
243934 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8599 {
8600 30 clk3^=1;
8601 30 }
8602
2/2
✓ Branch 0 taken 243892 times.
✓ Branch 1 taken 12 times.
243904 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8603 {
8604 12 clk3^=1;
8605 12 }
8606 244215 }
8607 else
8608 {
8609
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249066 times.
249342 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8610 {
8611 276 clk3^=1;
8612 276 }
8613
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249054 times.
249066 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8614 {
8615 12 clk3^=1;
8616 12 }
8617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249054 times.
249054 else if(ispitfall(x+16,y+8))
8618 {
8619 clk3^=1;
8620 }
8621
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249049 times.
249054 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8622 {
8623 5 clk3^=1;
8624 5 }
8625
2/2
✓ Branch 0 taken 249037 times.
✓ Branch 1 taken 12 times.
249049 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8626 {
8627 12 clk3^=1;
8628 12 }
8629 }
8630
8631 493557 --c;
8632
8633
4/4
✓ Branch 0 taken 151484 times.
✓ Branch 1 taken 342073 times.
✓ Branch 2 taken 320559 times.
✓ Branch 3 taken 172998 times.
493557 if(c<0 && step<zslongToFix(dstep*100))
8634 {
8635 172998 step+=zslongToFix(dmisc3*100);
8636 172998 }
8637
8638 493557 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8639
8640
2/2
✓ Branch 0 taken 492835 times.
✓ Branch 1 taken 722 times.
493557 if(x<=16-nb) clk3=right;
8641
8642
2/2
✓ Branch 0 taken 492566 times.
✓ Branch 1 taken 991 times.
493557 if(x>=world_w-32+nb) clk3=left;
8643
8644 493557 x += (clk3==left) ? -1 : 1;
8645
8646
4/4
✓ Branch 0 taken 29034 times.
✓ Branch 1 taken 464523 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454393 times.
493557 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8647 {
8648
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17283 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39164 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8649 {
8650 185 step=0-step;
8651 185 y--;
8652 185 }
8653
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12923 times.
18719 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8654 {
8655 12923 clk=misc=0;
8656 12923 } //land and jump again
8657 else
8658 {
8659 5796 misc=1;
8660 5796 clk2=0;
8661 }
8662 18904 }
8663
8664 473297 break;
8665 } // switch
8666 1259925 }
8667
8668
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059057 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400240 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8669 {
8670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8671 {
8672 int32_t tempy = floor_y;
8673 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8674 floor_y = y;
8675 y=tempy-fakez;
8676 old_y = y;
8677 }
8678 else
8679 {
8680 109977 int32_t tempy = floor_y;
8681
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8682 109977 floor_y = y;
8683 109977 y=tempy-z;
8684 109977 old_y = y;
8685 }
8686 109977 }
8687
8688
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1386676 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400240 if(stunclk && (clk&31)==1)
8689 10637 clk=0;
8690
8691 1400240 return enemy::animate(index);
8692 1426907 }
8693
8694 808713 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8695 {
8696
5/6
✓ Branch 0 taken 631435 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 631435 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 606244 times.
✓ Branch 5 taken 25191 times.
808713 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8697 25191 return;
8698
8699 783522 int32_t tempy=yofs;
8700 783522 int32_t fdiv = frate/4;
8701
1/2
✓ Branch 0 taken 783522 times.
✗ Branch 1 not taken.
783522 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8702
1/2
✓ Branch 0 taken 783522 times.
✗ Branch 1 not taken.
783522 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8703 783522 efrate:((clk>=(frate>>1))?1:0);
8704 783522 flip = 0;
8705 783522 shadowtile = wpnsbuf[spr_shadow].tile;
8706
8707
1/2
✓ Branch 0 taken 783522 times.
✗ Branch 1 not taken.
783522 if(get_qr(qr_NEWENEMYTILES))
8708 {
8709
2/2
✓ Branch 0 taken 581344 times.
✓ Branch 1 taken 202178 times.
783522 if(misc==0)
8710 {
8711 202178 shadowtile+=f2;
8712 202178 }
8713
2/2
✓ Branch 0 taken 259187 times.
✓ Branch 1 taken 322157 times.
581344 else if(misc!=1)
8714 322157 shadowtile+=2;
8715 783522 }
8716 else
8717 {
8718 if(misc==0)
8719 {
8720 shadowtile += f2 ? 1 : 0;
8721 }
8722 else if(misc!=1)
8723 {
8724 ++shadowtile;
8725 }
8726 }
8727
8728 783522 yofs+=8;
8729
8730
4/4
✓ Branch 0 taken 606244 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 344287 times.
✓ Branch 3 taken 261957 times.
783522 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8731 {
8732
6/6
✓ Branch 0 taken 134215 times.
✓ Branch 1 taken 127742 times.
✓ Branch 2 taken 244508 times.
✓ Branch 3 taken 17449 times.
✓ Branch 4 taken 123612 times.
✓ Branch 5 taken 120896 times.
261957 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8733 261957 }
8734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 783522 times.
783522 if(!shadow_overpit(this))
8735 783522 enemy::drawshadow(dest,translucent);
8736 783522 yofs=tempy;
8737 808713 }
8738
8739 2051295 void eTektite::draw(BITMAP *dest)
8740 {
8741 2051295 update_enemy_frame();
8742 2051295 enemy::draw(dest);
8743 2051295 }
8744
8745 731 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8746 731 {
8747
2/4
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 731 times.
✗ Branch 3 not taken.
731 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8748 731 superman=1;
8749 731 dir=8;
8750 731 hxofs=1000;
8751 731 mainguy=false;
8752 731 count_enemy=false;
8753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 731 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
731 if (SIZEflags != 0) init_size_flags();;
8754 731 }
8755
8756 280030 bool eItemFairy::animate(int32_t index)
8757 {
8758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280030 times.
280030 if(switch_hooked) return enemy::animate(index);
8759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280030 times.
280030 if(dying)
8760 return Dead(index);
8761
8762 //if(clk>32)
8763 280030 misc=1;
8764 280030 bool w=watch;
8765 280030 watch=false;
8766 280030 variable_walk_8(misc?3:0,0,8,spw_floater);
8767 280030 watch=w;
8768
8769
2/2
✓ Branch 0 taken 1515 times.
✓ Branch 1 taken 278515 times.
280030 if(clk==0)
8770 {
8771 1515 removearmos(x,y,ffcactivated);
8772 1515 }
8773
8774 280030 return enemy::animate(index);
8775 280030 }
8776
8777 562418 void eItemFairy::draw(BITMAP *dest)
8778 {
8779 //these are here to bypass compiler warnings about unused arguments
8780 562418 dest=dest;
8781 562418 }
8782
8783 1813 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8784 1813 {
8785 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8786
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1813 times.
✓ Branch 2 taken 1813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1813 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1813 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1813 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1813 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1813 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1813 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1813 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1813 times.
✗ Branch 19 not taken.
1813 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8787 1813 dir=8;
8788 1813 movestatus=1;
8789 1813 clk=0;
8790
1/2
✓ Branch 0 taken 1813 times.
✗ Branch 1 not taken.
1813 step=0;
8791 //nets+720;
8792
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1813 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1813 if (SIZEflags != 0) init_size_flags();;
8793 1813 }
8794
8795 518160 bool ePeahat::animate(int32_t index)
8796 {
8797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 518160 times.
518160 if(switch_hooked) return enemy::animate(index);
8798
2/4
✓ Branch 0 taken 518160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 518160 times.
518160 if(fallclk||drownclk) return enemy::animate(index);
8799
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 518082 times.
518160 if(slide())
8800 {
8801 78 return false;
8802 }
8803
8804
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 517052 times.
518082 if(dying)
8805 1030 return Dead(index);
8806
8807
2/2
✓ Branch 0 taken 3068 times.
✓ Branch 1 taken 513984 times.
517052 if(clk==0)
8808 {
8809 3068 removearmos(x,y,ffcactivated);
8810 3068 }
8811
8812
4/4
✓ Branch 0 taken 513934 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 252166 times.
✓ Branch 3 taken 261768 times.
517052 if(stunclk==0 && clk>96)
8813 261768 misc=1;
8814
8815
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 514650 times.
517052 if(!watch)
8816
2/2
✓ Branch 0 taken 170327 times.
✓ Branch 1 taken 344323 times.
514650 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8817
8818
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 417034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
517052 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8819 {
8820
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8821 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8822 100018 }
8823
8824
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 514650 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
517052 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8825 1634 superman=0;
8826 else
8827
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 505607 times.
515418 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8828 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8829
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 252115 times.
517052 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8830 {
8831
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8832 264937 }
8833 252115 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8834 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8835
8836
8837
2/2
✓ Branch 0 taken 516812 times.
✓ Branch 1 taken 240 times.
517052 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8838
8839 517052 return enemy::animate(index);
8840 518160 }
8841
8842 332065 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8843 {
8844 332065 int32_t tempy=yofs;
8845 332065 flip = 0;
8846 332065 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8847
8848
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 243976 times.
332065 if(!get_qr(qr_ENEMIESZAXIS))
8849 {
8850 243976 yofs+=8;
8851 243976 yofs+=int32_t(step/zslongToFix(dstep*10));
8852 243976 }
8853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332065 times.
332065 if(!shadow_overpit(this))
8854 332065 enemy::drawshadow(dest,translucent);
8855 332065 yofs=tempy;
8856 332065 }
8857
8858 1139420 void ePeahat::draw(BITMAP *dest)
8859 {
8860 1139420 update_enemy_frame();
8861 1139420 enemy::draw(dest);
8862 1139420 }
8863
8864 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8865 {
8866 4136 int32_t wpnId = w->id;
8867 4136 int32_t enemyHitWeapon = w->parentitem;
8868
8869
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8870 return 0;
8871
8872
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8873 // fire boomerang, for nailing peahats
8874
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8875 3343 return 0;
8876
8877 // Time for a kludge...
8878 793 int32_t s = superman;
8879 793 superman = 0;
8880 793 int32_t ret = enemy::takehit(w,realweap);
8881 793 superman = s;
8882
8883 // Anyway...
8884
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8885 {
8886 192 clk2=0;
8887 192 movestatus=0;
8888 192 misc=0;
8889 192 clk=0;
8890 192 step=0;
8891 192 }
8892
8893 793 return ret;
8894 4136 }
8895
8896 // auomatically kill off enemy (for rooms with ringleaders)
8897 void ePeahat::kickbucket()
8898 {
8899 hp=-1000; // don't call death_sfx()
8900 }
8901
8902 3912 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8903 3912 {
8904 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8905
2/2
✓ Branch 0 taken 1782 times.
✓ Branch 1 taken 2130 times.
3912 if(dmisc1==0)
8906 {
8907 2130 misc=-1; //Line of Sight leevers
8908 2130 clk-=16;
8909 2130 }
8910 3912 clk3 = 0;
8911 //nets+1460;
8912 3912 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8913 3912 submerged = false;
8914
1/4
✓ Branch 0 taken 3912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3912 if (SIZEflags != 0) init_size_flags();;
8915 3912 }
8916
8917 923 bool eLeever::isSubmerged() const
8918 {
8919 923 return misc <= 0;
8920 }
8921
8922 1013287 bool eLeever::animate(int32_t index)
8923 {
8924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1013287 times.
1013287 if(switch_hooked) return enemy::animate(index);
8925
3/4
✓ Branch 0 taken 1012932 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1012932 times.
1013287 if(fallclk||drownclk)
8926 {
8927 355 return enemy::animate(index);
8928 }
8929
2/2
✓ Branch 0 taken 31258 times.
✓ Branch 1 taken 981674 times.
1012932 if(dying)
8930 31258 return Dead(index);
8931
8932
2/2
✓ Branch 0 taken 936929 times.
✓ Branch 1 taken 44745 times.
981674 if(clk==0)
8933 {
8934 44745 removearmos(x,y,ffcactivated);
8935 44745 }
8936
8937
4/4
✓ Branch 0 taken 813267 times.
✓ Branch 1 taken 168407 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 808002 times.
981674 if(clk>=0 && !slide())
8938 {
8939
2/2
✓ Branch 0 taken 336207 times.
✓ Branch 1 taken 471795 times.
808002 switch(dmisc1)
8940 {
8941 case 0: //line of sight
8942 case 2:
8943
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124068 times.
✓ Branch 2 taken 48494 times.
✓ Branch 3 taken 35209 times.
✓ Branch 4 taken 15662 times.
✓ Branch 5 taken 101538 times.
✓ Branch 6 taken 4347 times.
✓ Branch 7 taken 6889 times.
336207 switch(misc) //is this leever active
8944 {
8945 case -1: //submerged
8946 {
8947
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 117686 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124068 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8948
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 113769 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124068 if((dmisc1==2)&&(zc_oldrand()&255))
8949 {
8950 10261 break;
8951 }
8952
8953 113807 int32_t active=0;
8954
8955
2/2
✓ Branch 0 taken 781349 times.
✓ Branch 1 taken 113807 times.
895156 for(int32_t i=0; i<guys.Count(); i++)
8956 {
8957
4/4
✓ Branch 0 taken 625905 times.
✓ Branch 1 taken 155444 times.
✓ Branch 2 taken 400969 times.
✓ Branch 3 taken 224936 times.
781349 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8958 {
8959 224936 ++active;
8960 224936 }
8961 781349 }
8962
8963
2/2
✓ Branch 0 taken 111951 times.
✓ Branch 1 taken 1856 times.
113807 if(active<((dmisc1==2)?1:2))
8964 {
8965 1856 misc=0; //activate this one
8966 1856 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8967 1856 }
8968 }
8969 113807 break;
8970
8971 case 0:
8972 {
8973
8974
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 36574 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
48494 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8975 {
8976 misc=1;
8977 clk2=0;
8978 }
8979
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 48437 times.
48494 else if (clk3<=0)
8980 {
8981 57 misc = -1;
8982 57 break;
8983 }
8984 48437 int32_t s=0;
8985
8986
2/2
✓ Branch 0 taken 269982 times.
✓ Branch 1 taken 48437 times.
318419 for(int32_t i=0; i<guys.Count(); i++)
8987 {
8988
4/4
✓ Branch 0 taken 162632 times.
✓ Branch 1 taken 107350 times.
✓ Branch 2 taken 154869 times.
✓ Branch 3 taken 7763 times.
269982 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8989 {
8990 7763 ++s;
8991 7763 }
8992 269982 }
8993
8994
2/2
✓ Branch 0 taken 7763 times.
✓ Branch 1 taken 40674 times.
48437 if(s>0)
8995 {
8996 7763 break;
8997 }
8998
8999 40674 int32_t d2=zc_oldrand()&1;
9000
9001
2/2
✓ Branch 0 taken 14188 times.
✓ Branch 1 taken 26486 times.
40674 if(HeroDir()>=left)
9002 {
9003 26486 d2+=2;
9004 26486 }
9005
9006
4/4
✓ Branch 0 taken 39233 times.
✓ Branch 1 taken 1441 times.
✓ Branch 2 taken 655 times.
✓ Branch 3 taken 38578 times.
40674 if(canplace(d2) || canplace(d2^1))
9007 {
9008 2096 misc=1;
9009 2096 clk2=0;
9010 2096 clk=0;
9011 2096 }
9012 }
9013 40674 break;
9014
9015 case 1:
9016
9017
7/8
✓ Branch 0 taken 33157 times.
✓ Branch 1 taken 2052 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29561 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35209 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9018
9019 35209 break;
9020
9021 case 2:
9022
9023
7/8
✓ Branch 0 taken 13761 times.
✓ Branch 1 taken 1901 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12258 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15662 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9024
9025 15662 break;
9026
9027 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9028 case 3:
9029
9030
5/6
✓ Branch 0 taken 97949 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 97949 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95222 times.
101538 if(stunclk || frozenclock || watch) break;
9031
9032
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 95082 times.
95222 if(scored) dir^=1;
9033
9034
2/2
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 94720 times.
95222 if(!canmove(dir,false)) misc=4;
9035 94720 else move(zslongToFix(dstep*100));
9036
9037 95222 break;
9038
9039 case 4:
9040
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3737 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4347 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9041
2/2
✓ Branch 0 taken 3881 times.
✓ Branch 1 taken 466 times.
4347 if(--clk2<=16)
9042 {
9043 466 misc=5;
9044 466 clk=8;
9045 466 }
9046
9047 4347 break;
9048
9049 case 5:
9050
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5879 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6889 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9051
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 409 times.
6889 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9052
9053 6889 break;
9054 } // switch(misc)
9055
9056 336207 break;
9057
9058 default: //random
9059 // step=d->misc3/100.0;
9060
9061 471795 step=zslongToFix(dmisc3*100);
9062
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 471795 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
471795 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9063 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9064 {
9065 if (clk2 < 48) clk2+=2;
9066 if (clk2 >= 300) clk2-=2;
9067 }
9068
9069
2/2
✓ Branch 0 taken 60437 times.
✓ Branch 1 taken 411358 times.
471795 if(clk2<32) misc=1;
9070
2/2
✓ Branch 0 taken 30036 times.
✓ Branch 1 taken 381322 times.
411358 else if(clk2<48) misc=2;
9071
2/2
✓ Branch 0 taken 288285 times.
✓ Branch 1 taken 93037 times.
381322 else if(clk2<300)
9072 {
9073 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9074 {
9075 fix_coords();
9076 }*/
9077 288285 misc=3;
9078 288285 step = zslongToFix(dstep*100);
9079 288285 }
9080
2/2
✓ Branch 0 taken 8993 times.
✓ Branch 1 taken 84044 times.
93037 else if(clk2<316) misc=2;
9081
2/2
✓ Branch 0 taken 43659 times.
✓ Branch 1 taken 40385 times.
84044 else if(clk2<412) misc=1;
9082
2/2
✓ Branch 0 taken 40111 times.
✓ Branch 1 taken 274 times.
40385 else if(clk2<540)
9083 {
9084 40111 misc=0;
9085 40111 step=0;
9086 40111 }
9087 274 else clk2=0;
9088
9089
2/2
✓ Branch 0 taken 469955 times.
✓ Branch 1 taken 1840 times.
471795 if(clk2==48) clk=0;
9090
9091 // variable_walk(d->rate, d->homing, 0);
9092 471795 variable_walk(rate, homing, 0);
9093 471795 } // switch(dmisc1)
9094 808002 }
9095
9096 981674 hxofs=(misc>=2)?0:1000;
9097 981674 return enemy::animate(index);
9098 1013287 }
9099
9100 79907 bool eLeever::canplace(int32_t d2)
9101 {
9102 79907 int32_t nx=HeroX();
9103 79907 int32_t ny=HeroY();
9104
9105
2/2
✓ Branch 0 taken 27852 times.
✓ Branch 1 taken 52055 times.
79907 if(d2<left) ny=TRUNCATE_TILE(ny);
9106 52055 else nx=TRUNCATE_TILE(nx);
9107
9108
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13853 times.
✓ Branch 2 taken 13999 times.
✓ Branch 3 taken 26008 times.
✓ Branch 4 taken 26047 times.
79907 switch(d2)
9109 {
9110 case up:
9111
2/2
✓ Branch 0 taken 13823 times.
✓ Branch 1 taken 30 times.
13853 ny-=((dmisc1==0||dmisc1==2)?32:48);
9112 13853 break;
9113
9114 case down:
9115
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 13965 times.
13999 ny+=((dmisc1==0||dmisc1==2)?32:48);
9116
9117
4/4
✓ Branch 0 taken 9926 times.
✓ Branch 1 taken 4073 times.
✓ Branch 2 taken 9915 times.
✓ Branch 3 taken 11 times.
13999 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9118
9119 13999 break;
9120
9121 case left:
9122
2/2
✓ Branch 0 taken 25355 times.
✓ Branch 1 taken 653 times.
26008 nx-=((dmisc1==0||dmisc1==2)?32:48);
9123 26008 break;
9124
9125 case right:
9126
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25401 times.
26047 nx+=((dmisc1==0||dmisc1==2)?32:48);
9127
9128
4/4
✓ Branch 0 taken 18992 times.
✓ Branch 1 taken 7055 times.
✓ Branch 2 taken 18390 times.
✓ Branch 3 taken 602 times.
26047 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9129
9130 26047 break;
9131 }
9132
9133
4/4
✓ Branch 0 taken 20337 times.
✓ Branch 1 taken 59570 times.
✓ Branch 2 taken 8955 times.
✓ Branch 3 taken 11382 times.
79907 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9134 68525 return false;
9135
9136
2/2
✓ Branch 0 taken 859 times.
✓ Branch 1 taken 10523 times.
11382 if(d2>=left)
9137
4/4
✓ Branch 0 taken 5000 times.
✓ Branch 1 taken 5523 times.
✓ Branch 2 taken 9286 times.
✓ Branch 3 taken 1237 times.
10523 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9138 9286 return false;
9139
9140 2096 x=nx;
9141 2096 y=ny;
9142 2096 dir=d2^1;
9143 2096 return true;
9144 79907 }
9145
9146 1019190 void eLeever::draw(BITMAP *dest)
9147 {
9148 // cs=d->cset;
9149 1019190 cs=dcset;
9150 1019190 update_enemy_frame();
9151
3/4
✓ Branch 0 taken 1018835 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018835 times.
1019190 if(!fallclk&&!drownclk)
9152 {
9153
2/2
✓ Branch 0 taken 634172 times.
✓ Branch 1 taken 384663 times.
1018835 switch(misc)
9154 {
9155 case -1:
9156 case 0:
9157 384663 return;
9158 }
9159 634172 }
9160
9161 634527 enemy::draw(dest);
9162 1019190 }
9163
9164 977 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9165 977 {
9166 977 hashero=false;
9167 //nets+1000;
9168
1/4
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
977 if (SIZEflags != 0) init_size_flags();;
9169 977 }
9170
9171 497782 bool eWallM::animate(int32_t index)
9172 {
9173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497782 times.
497782 if(switch_hooked) return enemy::animate(index);
9174
2/4
✓ Branch 0 taken 497782 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 497782 times.
497782 if(fallclk||drownclk)
9175 {
9176 return enemy::animate(index);
9177 }
9178
2/2
✓ Branch 0 taken 9730 times.
✓ Branch 1 taken 488052 times.
497782 if(dying)
9179 9730 return Dead(index);
9180
9181
2/2
✓ Branch 0 taken 457492 times.
✓ Branch 1 taken 30560 times.
488052 if(clk==0)
9182 {
9183 30560 removearmos(x,y,ffcactivated);
9184 30560 }
9185
9186 488052 hxofs=1000;
9187
2/2
✓ Branch 0 taken 116644 times.
✓ Branch 1 taken 371408 times.
488052 if(misc==0) //inside wall, ready to spawn?
9188 {
9189
4/4
✓ Branch 0 taken 225986 times.
✓ Branch 1 taken 145422 times.
✓ Branch 2 taken 16408 times.
✓ Branch 3 taken 209578 times.
371408 if(frame-wallm_load_clk>80 && clk>=0)
9190 {
9191 209578 int32_t wall=hero_on_wall();
9192 209578 int32_t wallm_cnt=0;
9193
9194
2/2
✓ Branch 0 taken 1659364 times.
✓ Branch 1 taken 209578 times.
1868942 for(int32_t i=0; i<guys.Count(); i++)
9195
2/2
✓ Branch 0 taken 653886 times.
✓ Branch 1 taken 1005478 times.
2664842 if(((enemy*)guys.spr(i))->family==eeWALLM)
9196 {
9197 1005478 int32_t m=((enemy*)guys.spr(i))->misc;
9198
9199
4/4
✓ Branch 0 taken 49982 times.
✓ Branch 1 taken 955496 times.
✓ Branch 2 taken 36616 times.
✓ Branch 3 taken 13366 times.
1005478 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9200 {
9201 13366 ++wallm_cnt;
9202 13366 }
9203 1005478 }
9204
9205
2/2
✓ Branch 0 taken 208751 times.
✓ Branch 1 taken 827 times.
209578 if(wall>0)
9206 {
9207 827 --wall;
9208 827 misc=1; //emerging from the wall?
9209 827 clk2=0;
9210 827 clk3=wall^1;
9211 827 wallm_load_clk=frame;
9212
9213
2/2
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 321 times.
827 if(wall<=down)
9214 {
9215
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 417 times.
506 if(HeroDir()==left)
9216 89 dir=right;
9217 else
9218 417 dir=left;
9219 506 }
9220 else
9221 {
9222
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 256 times.
321 if(HeroDir()==up)
9223 65 dir=down;
9224 else
9225 256 dir=up;
9226 }
9227
9228
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 277 times.
✓ Branch 3 taken 220 times.
✓ Branch 4 taken 101 times.
827 switch(wall)
9229 {
9230 case up:
9231 229 y=0;
9232 229 break;
9233
9234 case down:
9235 277 y=160;
9236 277 break;
9237
9238 case left:
9239 220 x=0;
9240 220 break;
9241
9242 case right:
9243 101 x=240;
9244 101 break;
9245 }
9246
9247
9248
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 417 times.
✓ Branch 4 taken 89 times.
827 switch(dir)
9249 {
9250 case up:
9251 256 y=(HeroY()+48-(wallm_cnt&1)*12);
9252 256 flip=wall&1;
9253 256 break;
9254
9255 case down:
9256 65 y=(HeroY()-48+(wallm_cnt&1)*12);
9257 65 flip=((wall&1)^1)+2;
9258 65 break;
9259
9260 case left:
9261 417 x=(HeroX()+48-(wallm_cnt&1)*12);
9262 417 flip=(wall==up?2:0)+1;
9263 417 break;
9264
9265 case right:
9266 89 x=(HeroX()-48+(wallm_cnt&1)*12);
9267 89 flip=(wall==up?2:0);
9268 89 break;
9269 }
9270
9271 827 }
9272 209578 }
9273 371408 }
9274 else
9275 116644 wallm_crawl();
9276
9277 488052 return enemy::animate(index);
9278 497782 }
9279
9280 116644 void eWallM::wallm_crawl()
9281 {
9282 116644 bool w=watch;
9283 116644 hxofs=0;
9284
9285
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 115834 times.
116644 if(slide())
9286 {
9287 810 return;
9288 }
9289
9290 // if(dying || watch || (!hashero && stunclk))
9291
6/8
✓ Branch 0 taken 115834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114505 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 99959 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 99959 times.
115834 if(dying || (!hashero && ( stunclk || frozenclock )))
9292 {
9293 14546 return;
9294 }
9295
9296 101288 watch=false;
9297 101288 ++clk2;
9298 // Misc1: slightly different movement
9299 101288 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9300
9301 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101288 times.
101288 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9303
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 95071 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
101288 if(w&&misc>=3&&misc<=5)
9304 {
9305 4491 --clk2;
9306 4491 }
9307
9308
4/4
✓ Branch 0 taken 39185 times.
✓ Branch 1 taken 52056 times.
✓ Branch 2 taken 9904 times.
✓ Branch 3 taken 143 times.
101288 switch(misc)
9309 {
9310 case 1:
9311 case 2:
9312 52056 zc_swap(dir,clk3);
9313 52056 move(step);
9314 52056 zc_swap(dir,clk3);
9315 52056 break;
9316
9317 case 3:
9318 case 4:
9319 case 5:
9320
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34694 times.
39185 if(w)
9321 {
9322 4491 watch=w;
9323 4491 return;
9324 }
9325
9326 34694 move(step);
9327 34694 break;
9328
9329 case 6:
9330 case 7:
9331 9904 zc_swap(dir,clk3);
9332 9904 dir^=1;
9333 9904 move(step);
9334 9904 dir^=1;
9335 9904 zc_swap(dir,clk3);
9336 9904 break;
9337
9338 default:
9339 143 misc=0;
9340 143 break;
9341 }
9342
9343 96797 watch=w;
9344 116644 }
9345
9346 9 void eWallM::grabhero()
9347 {
9348 9 hashero=true;
9349 9 superman=1;
9350 9 }
9351
9352 500167 void eWallM::draw(BITMAP *dest)
9353 {
9354 500167 dummy_bool[1]=hashero;
9355 500167 update_enemy_frame();
9356
9357
4/6
✓ Branch 0 taken 372200 times.
✓ Branch 1 taken 127967 times.
✓ Branch 2 taken 372200 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 372200 times.
500167 if(misc>0 || fallclk||drownclk)
9358 {
9359 127967 masked_draw(dest,16,playing_field_offset+16,224,144);
9360 127967 }
9361
9362 // enemy::draw(dest);
9363 // tile = clk&8 ? 128:129;
9364 500167 }
9365
9366 bool eWallM::isSubmerged() const
9367 {
9368 return ( !misc );
9369 }
9370
9371 1623 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9372 1623 {
9373
1/2
✓ Branch 0 taken 1623 times.
✗ Branch 1 not taken.
1623 ox=x; //original x
9374
1/2
✓ Branch 0 taken 1623 times.
✗ Branch 1 not taken.
1623 oy=y; //original y
9375
2/2
✓ Branch 0 taken 1457 times.
✓ Branch 1 taken 166 times.
1623 if(get_qr(qr_TRAPPOSFIX))
9376 {
9377
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9378 166 }
9379
9380 1623 mainguy=false;
9381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1623 times.
1623 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9382 //nets+420;
9383 1623 dummy_int[1]=0;
9384
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1623 if (SIZEflags != 0) init_size_flags();;
9385 1623 }
9386
9387 1038008 bool eTrap::animate(int32_t index)
9388 {
9389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1038008 times.
1038008 if(switch_hooked) return enemy::animate(index);
9390
2/4
✓ Branch 0 taken 1038008 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1038008 times.
1038008 if(fallclk||drownclk) return enemy::animate(index);
9391
2/2
✓ Branch 0 taken 1016592 times.
✓ Branch 1 taken 21416 times.
1038008 if(clk<0)
9392 21416 return enemy::animate(index);
9393
9394
2/2
✓ Branch 0 taken 952294 times.
✓ Branch 1 taken 64298 times.
1016592 if(clk==0)
9395 {
9396 64298 removearmos(x,y,ffcactivated);
9397 64298 }
9398
9399
2/2
✓ Branch 0 taken 316909 times.
✓ Branch 1 taken 699683 times.
1016592 if(misc==0) // waiting
9400 {
9401 699683 ox = x;
9402 699683 oy = y;
9403 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9404 699683 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9405
9406
4/4
✓ Branch 0 taken 241398 times.
✓ Branch 1 taken 458285 times.
✓ Branch 2 taken 133399 times.
✓ Branch 3 taken 107999 times.
699683 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9407 {
9408 107999 dir=down;
9409 107999 }
9410
4/4
✓ Branch 0 taken 392414 times.
✓ Branch 1 taken 199270 times.
✓ Branch 2 taken 133399 times.
✓ Branch 3 taken 259015 times.
591684 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9411 {
9412 259015 dir=right;
9413 259015 }
9414
4/4
✓ Branch 0 taken 211789 times.
✓ Branch 1 taken 120880 times.
✓ Branch 2 taken 133399 times.
✓ Branch 3 taken 78390 times.
332669 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9415 {
9416 78390 dir=up;
9417 78390 }
9418 else
9419 {
9420 254279 dir=left;
9421 }
9422
9423 699683 int32_t d2=lined_up(15,true);
9424
9425
4/4
✓ Branch 0 taken 268318 times.
✓ Branch 1 taken 431365 times.
✓ Branch 2 taken 1107243 times.
✓ Branch 3 taken 407560 times.
1093330 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9426
2/2
✓ Branch 0 taken 232338 times.
✓ Branch 1 taken 175222 times.
407560 ((d2>down) && (dmisc1==2)) ||
9427
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 80047 times.
175222 ((d2>right) && (!dmisc1)) ||
9428
2/2
✓ Branch 0 taken 393647 times.
✓ Branch 1 taken 126531 times.
267116 ((d2<l_up) && (dmisc1==4)) ||
9429
3/4
✓ Branch 0 taken 393647 times.
✓ Branch 1 taken 267116 times.
✓ Branch 2 taken 393647 times.
✗ Branch 3 not taken.
126531 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9430
3/4
✓ Branch 0 taken 393647 times.
✓ Branch 1 taken 126531 times.
✓ Branch 2 taken 393647 times.
✗ Branch 3 not taken.
267116 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9431 {
9432 2520522 d2=-1;
9433 2520522 }
9434
9435
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 411891 times.
✓ Branch 2 taken 18573 times.
✓ Branch 3 taken 2103 times.
432567 if(d2!=-1 && trapmove(d2))
9436 {
9437 2103 dir=d2;
9438 2103 misc=1;
9439 2103 clk2=(dir==down)?3:0;
9440 2103 }
9441 432567 }
9442
9443
2/2
✓ Branch 0 taken 660570 times.
✓ Branch 1 taken 88906 times.
749476 if(misc==1) // charging
9444 {
9445 88906 clk2=(clk2+1)&3;
9446 88906 step=(clk2==3)?1:2;
9447
9448
4/4
✓ Branch 0 taken 88114 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87009 times.
88906 if(!trapmove(dir) || clip())
9449 {
9450 1897 misc=2;
9451
9452
1/2
✓ Branch 0 taken 1897 times.
✗ Branch 1 not taken.
1897 if(dir<l_up)
9453 {
9454 1897 dir=dir^1;
9455 1897 }
9456 else
9457 {
9458 dir=dir^3;
9459 }
9460 1897 }
9461 else
9462 {
9463 87009 sprite::move(step);
9464 }
9465 88906 }
9466
9467
2/2
✓ Branch 0 taken 517473 times.
✓ Branch 1 taken 232003 times.
749476 if(misc==2) // retreating
9468 {
9469 232003 step=(++clk2&1)?1:0;
9470
9471
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 38899 times.
✓ Branch 2 taken 80820 times.
✓ Branch 3 taken 29017 times.
✓ Branch 4 taken 83267 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
232003 switch(dir)
9472 {
9473 case up:
9474
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38627 times.
38899 if(int32_t(y)<=oy) goto trap_rest;
9475 38627 else sprite::move(step);
9476
9477 38627 break;
9478
9479 case left:
9480
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 80429 times.
80820 if(int32_t(x)<=ox) goto trap_rest;
9481 80429 else sprite::move(step);
9482
9483 80429 break;
9484
9485 case down:
9486
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28793 times.
29017 if(int32_t(y)>=oy) goto trap_rest;
9487 28793 else sprite::move(step);
9488
9489 28793 break;
9490
9491 case right:
9492
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 82837 times.
83267 if(int32_t(x)>=ox) goto trap_rest;
9493 82837 else sprite::move(step);
9494
9495 82837 break;
9496
9497 case l_up:
9498 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9499 else sprite::move(step);
9500
9501 break;
9502
9503 case r_up:
9504 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9505 else sprite::move(step);
9506
9507 break;
9508
9509 case l_down:
9510 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9511 else sprite::move(step);
9512
9513 break;
9514
9515 case r_down:
9516 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9517 else sprite::move(step);
9518
9519 break;
9520 trap_rest:
9521 {
9522 1317 x=ox;
9523 1317 y=oy;
9524 1317 misc=0;
9525 }
9526 1317 }
9527 232003 }
9528
9529 749476 return enemy::animate(index);
9530 770892 }
9531
9532 109582 bool eTrap::trapmove(int32_t ndir)
9533 {
9534
2/2
✓ Branch 0 taken 79818 times.
✓ Branch 1 taken 29764 times.
109582 if(get_qr(qr_MEANTRAPS))
9535 {
9536 79818 mapscr* scr = get_scr(screen_spawned);
9537
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 78478 times.
79818 if(scr->flags2&fFLOATTRAPS)
9538 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9539
9540 78478 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9541 }
9542
9543
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9544 4730 return false;
9545
9546
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9547 return false;
9548
9549
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9550 return false;
9551
9552
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9553 return false;
9554
9555
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9556 4722 return false;
9557
9558
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9559 713 return false;
9560
9561
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9562 return false;
9563
9564
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9565 return false;
9566
9567
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9568 return false;
9569
9570
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9571 return false;
9572
9573 19599 return true;
9574 109582 }
9575
9576 88114 bool eTrap::clip()
9577 {
9578
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45092 times.
88114 if(get_qr(qr_MEANPLACEDTRAPS))
9579 {
9580
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5720 times.
✓ Branch 2 taken 8584 times.
✓ Branch 3 taken 15602 times.
✓ Branch 4 taken 15186 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45092 switch(dir)
9581 {
9582 case up:
9583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5720 times.
5720 if(y<=0) return true;
9584
9585 5720 break;
9586
9587 case down:
9588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8584 times.
8584 if(y>=world_h-16) return true;
9589
9590 8584 break;
9591
9592 case left:
9593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15602 times.
15602 if(x<=0) return true;
9594
9595 15602 break;
9596
9597 case right:
9598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15186 times.
15186 if(x>=world_w-16) return true;
9599
9600 15186 break;
9601
9602 case l_up:
9603 if(y<=0||x<=0) return true;
9604
9605 break;
9606
9607 case l_down:
9608 if(y>=world_h-16||x<=0) return true;
9609
9610 break;
9611
9612 case r_up:
9613 if(y<=0||x>=world_w-16) return true;
9614
9615 break;
9616
9617 case r_down:
9618 if(y>=world_h-16||x>=world_w-16) return true;
9619
9620 break;
9621 }
9622
9623 45092 return false;
9624 }
9625 else
9626 {
9627
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9628 {
9629 case up:
9630
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9631
9632 4695 break;
9633
9634 case down:
9635
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9636
9637 5253 break;
9638
9639 case left:
9640
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9641
9642 16376 break;
9643
9644 case right:
9645
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9646
9647 15593 break;
9648
9649 case l_up:
9650 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9651
9652 break;
9653
9654 case l_down:
9655 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9656
9657 break;
9658
9659 case r_up:
9660 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9661
9662 break;
9663
9664 case r_down:
9665 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9666
9667 break;
9668 }
9669
9670 41917 return false;
9671 }
9672 88114 }
9673
9674 1056916 void eTrap::draw(BITMAP *dest)
9675 {
9676 1056916 update_enemy_frame();
9677 1056916 enemy::draw(dest);
9678 1056916 }
9679
9680 5679 int32_t eTrap::takehit(weapon*,weapon*)
9681 {
9682 5679 return 0;
9683 }
9684
9685 831 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9686 831 {
9687 831 lasthit=-1;
9688 831 lasthitclk=0;
9689 831 mainguy=false;
9690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
831 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9691
1/2
✓ Branch 0 taken 831 times.
✗ Branch 1 not taken.
831 step=2;
9692
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
831 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9693 {
9694
2/4
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 398 times.
✗ Branch 3 not taken.
398 dir=(x<=112)?right:left;
9695 398 }
9696 else
9697 {
9698
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9699 }
9700
9701
2/2
✓ Branch 0 taken 759 times.
✓ Branch 1 taken 72 times.
831 if(get_qr(qr_TRAPPOSFIX))
9702 {
9703
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9704 72 }
9705
9706 //nets+((id==eTRAP_LR)?540:520);
9707 831 dummy_int[1]=0;
9708
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
831 if (SIZEflags != 0) init_size_flags();;
9709 831 }
9710
9711 346397 bool eTrap2::animate(int32_t index)
9712 {
9713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346397 times.
346397 if(switch_hooked) return enemy::animate(index);
9714
2/4
✓ Branch 0 taken 346397 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346397 times.
346397 if(fallclk||drownclk) return enemy::animate(index);
9715
2/2
✓ Branch 0 taken 335385 times.
✓ Branch 1 taken 11012 times.
346397 if(clk<0)
9716 11012 return enemy::animate(index);
9717
9718
2/2
✓ Branch 0 taken 21375 times.
✓ Branch 1 taken 314010 times.
335385 if(clk==0)
9719 {
9720 21375 removearmos(x,y,ffcactivated);
9721 21375 }
9722
9723
2/2
✓ Branch 0 taken 211059 times.
✓ Branch 1 taken 124326 times.
335385 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9724 {
9725
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9726 {
9727 11074 --lasthitclk;
9728 11074 }
9729 else
9730 {
9731 113252 lasthit=-1;
9732 }
9733
9734 124326 bool hitenemy=false;
9735
9736
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9737 {
9738
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9739 {
9740
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9741 {
9742 3669 lasthit=j;
9743 3669 lasthitclk=10;
9744 3669 hitenemy=true;
9745 3669 guys.spr(j)->lasthit=index;
9746 3669 guys.spr(j)->lasthitclk=10;
9747 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9748 3669 }
9749 730351 }
9750 864860 }
9751
9752
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9753 {
9754
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9755 {
9756 3155 lasthit=-1;
9757 3155 lasthitclk=0;
9758 3155 }
9759
9760
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9761 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9762
9763 5986 dir=dir^1;
9764 5986 }
9765
9766 124326 sprite::move(step);
9767 124326 }
9768 else
9769 {
9770
3/4
✓ Branch 0 taken 204144 times.
✓ Branch 1 taken 6915 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204144 times.
211059 if(!trapmove(dir) || clip())
9771 {
9772
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 1521 times.
6915 if(get_qr(qr_MORESOUNDS))
9773 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9774
9775 6915 dir=dir^1;
9776 6915 }
9777
9778 211059 sprite::move(step);
9779 }
9780
9781 335385 return enemy::animate(index);
9782 346397 }
9783
9784 341371 bool eTrap2::trapmove(int32_t ndir)
9785 {
9786 341371 mapscr* scr = get_scr(screen_spawned);
9787
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339493 times.
341371 if(scr->flags2&fFLOATTRAPS)
9788 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9789
9790 339493 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9791 341371 }
9792
9793 328146 bool eTrap2::clip()
9794 {
9795
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75075 times.
✓ Branch 4 taken 75722 times.
328146 switch(dir)
9796 {
9797 case up:
9798
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9799
9800 88320 break;
9801
9802 case down:
9803
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9804
9805 89029 break;
9806
9807 case left:
9808
1/2
✓ Branch 0 taken 75075 times.
✗ Branch 1 not taken.
75075 if(x<=0) return true;
9809
9810 75075 break;
9811
9812 case right:
9813
1/2
✓ Branch 0 taken 75722 times.
✗ Branch 1 not taken.
75722 if(x>=world_w-16) return true;
9814
9815 75722 break;
9816 }
9817
9818 328146 return false;
9819 328146 }
9820
9821 350771 void eTrap2::draw(BITMAP *dest)
9822 {
9823 350771 update_enemy_frame();
9824 350771 enemy::draw(dest);
9825 350771 }
9826
9827 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9828 {
9829 3169 return 0;
9830 }
9831
9832 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9833 354 {
9834 //do not show "enemy appering" anim -DD
9835 354 clk=0;
9836 354 mainguy=false;
9837 354 clk2=-14;
9838 //Enemy Editor Size Tab
9839
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9840 //nets+1640;
9841 354 }
9842
9843 354 void eRock::init_size_flags()
9844 {
9845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9846 354 else hxofs = -2;
9847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9848 354 else hyofs = -2;
9849
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9850 354 else hit_width = 20;
9851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9852 354 else hit_height = 20;
9853
9854
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9855
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9856
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9857
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9858
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9859 {
9860 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9861 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9862 }
9863
9864
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9865 354 }
9866
9867 121997 bool eRock::animate(int32_t index)
9868 {
9869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9870
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9872 return Dead(index);
9873
9874
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9875 {
9876 8376 removearmos(x,y,ffcactivated);
9877 8376 }
9878
9879
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9880 {
9881 697 x=zc_oldrand()&0xF0;
9882 697 y=0;
9883 697 clk3=0;
9884 697 clk2=zc_oldrand()&15;
9885 697 }
9886
9887
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9888 {
9889
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9890 {
9891 3430 dir=zc_oldrand()&1;
9892
9893
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9894
9895
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9896 3430 }
9897
9898
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9899 {
9900 95993 x += dir ? 1 : -1; //right, left
9901 95993 dummy_int[1]=dir;
9902
9903
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9904 {
9905 6852 y-=2; //up
9906 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9907 6852 }
9908
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9909 {
9910 10208 y--; //up
9911 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9912 10208 }
9913
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9914 {
9915 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9916 10135 }
9917
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9918 {
9919 10058 y++; //down
9920 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9921 10058 }
9922 else
9923 {
9924 58740 y+=2; //down
9925 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9926 }
9927
9928 95993 ++clk3;
9929 95993 }
9930
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9931 2761 clk3=0; // next bounce
9932 else
9933 423 clk2 = -(zc_oldrand()&63); // back to top
9934 99177 }
9935
9936 121997 return enemy::animate(index);
9937 121997 }
9938
9939 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9940 {
9941
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9942 {
9943 44250 int32_t tempy=yofs;
9944 44250 flip = 0;
9945 44250 int32_t fdiv = frate/4;
9946
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9947
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9948 44250 efrate:((clk>=(frate>>1))?1:0);
9949 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9950
9951 44250 yofs+=8;
9952
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9954 44250 sprite::drawshadow(dest, translucent);
9955 44250 yofs=tempy;
9956 44250 }
9957 51441 }
9958
9959 122078 void eRock::draw(BITMAP *dest)
9960 {
9961
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9962 {
9963 105043 int32_t tempdir=dir;
9964 105043 dir=dummy_int[2];
9965 105043 update_enemy_frame();
9966 105043 enemy::draw(dest);
9967 105043 dir=tempdir;
9968 105043 }
9969 122078 }
9970
9971 1014 int32_t eRock::takehit(weapon*,weapon*)
9972 {
9973 1014 return 0;
9974 }
9975
9976 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9977 30 {
9978 30 clk=0;
9979 30 mainguy=false;
9980 30 clk2=-14;
9981
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9982 //nets+1680;
9983 30 }
9984
9985 4440 bool eBoulder::animate(int32_t index)
9986 {
9987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9988
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9990 return Dead(index);
9991
9992
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9993 {
9994 290 removearmos(x,y,ffcactivated);
9995 290 }
9996
9997 zfix *vert;
9998
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9999
10000
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10001 {
10002 32 x=zc_oldrand()&0xF0;
10003 32 y=-32;
10004 32 clk3=0;
10005 32 clk2=zc_oldrand()&15;
10006 32 }
10007
10008
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10009 {
10010
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10011 {
10012 131 dir=zc_oldrand()&1;
10013
10014
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10015
10016
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10017 131 }
10018
10019
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10020 {
10021 3487 x += dir ? 1 : -1; //right, left
10022 3487 dummy_int[1]=dir;
10023
10024
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10025 {
10026 261 y-=2; //up
10027 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10028 261 }
10029
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10030 {
10031 382 y--; //up
10032 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10033 382 }
10034
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10035 {
10036 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10037 376 }
10038
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10039 {
10040 367 y++; //down
10041 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10042 367 }
10043 else
10044 {
10045 2101 y+=2; //down
10046 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10047 }
10048
10049 3487 ++clk3;
10050 3487 }
10051
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10052 101 clk3=0; // next bounce
10053 else
10054 10 clk2 = -(zc_oldrand()&63); // back to top
10055 3598 }
10056
10057 4440 return enemy::animate(index);
10058 4440 }
10059
10060 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10061 {
10062
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10063 {
10064 3868 int32_t tempy=yofs;
10065 3868 flip = 0;
10066 3868 int32_t f2=((clk<<2)/frate)<<1;
10067 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10068
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10069
10070 3868 yofs+=8;
10071 3868 xofs-=8;
10072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10073 3868 sprite::drawshadow(dest, translucent);
10074 3868 xofs+=16;
10075 3868 ++shadowtile;
10076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10077 3868 sprite::drawshadow(dest, translucent);
10078 3868 yofs+=16;
10079 3868 shadowtile+=20;
10080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10081 3868 sprite::drawshadow(dest, translucent);
10082 3868 xofs-=16;
10083 3868 --shadowtile;
10084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10085 3868 sprite::drawshadow(dest, translucent);
10086 3868 xofs+=8;
10087 3868 yofs=tempy;
10088 3868 }
10089 4440 }
10090
10091 4440 void eBoulder::draw(BITMAP *dest)
10092 {
10093
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10094 {
10095 3868 int32_t tempdir=dir;
10096 3868 dir=dummy_int[2];
10097 3868 update_enemy_frame();
10098 3868 dir=tempdir;
10099 3868 xofs-=8;
10100 3868 yofs-=8;
10101 3868 drawblock(dest,15);
10102 3868 xofs+=8;
10103 3868 yofs+=8;
10104 // enemy::draw(dest);
10105 3868 }
10106 4440 }
10107
10108 30 void eBoulder::init_size_flags()
10109 {
10110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10111 30 else hxofs = -10;
10112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10113 30 else hyofs = -10;
10114
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10115 30 else hit_width = 36;
10116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10117 30 else hit_height = 36;
10118
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10119 30 else hzsz = 16; //can't be jumped
10120
10121
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10122
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10124
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10125
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10126 {
10127 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10128 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10129 }
10130
10131
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10132 30 }
10133
10134 int32_t eBoulder::takehit(weapon*,weapon*)
10135 {
10136 return 0;
10137 }
10138
10139 4381 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10140
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3850 times.
4381 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10141 4381 {
10142 /* fixing
10143 hp=1;
10144 */
10145 4381 mainguy=false;
10146
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4374 times.
4381 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10147 4381 hclk=clk; // the "no fire" range
10148 4381 clk=0;
10149 4381 clk3=96;
10150 4381 timer=0;
10151
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4367 times.
4381 if(o_tile==0)
10152 {
10153 4367 superman=1;
10154 4367 hxofs=1000;
10155 4367 }
10156
1/4
✓ Branch 0 taken 4381 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4381 if (SIZEflags != 0) init_size_flags();;
10157 4381 }
10158
10159 2478596 bool eProjectile::animate(int32_t index)
10160 {
10161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2478596 times.
2478596 if(switch_hooked) return enemy::animate(index);
10162
2/4
✓ Branch 0 taken 2478596 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2478596 times.
2478596 if(fallclk||drownclk) return enemy::animate(index);
10163
2/2
✓ Branch 0 taken 2466400 times.
✓ Branch 1 taken 12196 times.
2478596 if(clk==0)
10164 {
10165 12196 removearmos(x,y,ffcactivated);
10166 12196 }
10167
10168 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10169 2478596 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10170
10171
4/4
✓ Branch 0 taken 824623 times.
✓ Branch 1 taken 1653973 times.
✓ Branch 2 taken 425336 times.
✓ Branch 3 taken 399287 times.
2478596 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10172 {
10173 399287 dir=down;
10174 399287 }
10175
4/4
✓ Branch 0 taken 1334494 times.
✓ Branch 1 taken 744815 times.
✓ Branch 2 taken 425336 times.
✓ Branch 3 taken 909158 times.
2079309 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10176 {
10177 909158 dir=right;
10178 909158 }
10179
4/4
✓ Branch 0 taken 779821 times.
✓ Branch 1 taken 390330 times.
✓ Branch 2 taken 425336 times.
✓ Branch 3 taken 354485 times.
1170151 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10180 {
10181 354485 dir=up;
10182 354485 }
10183 else
10184 {
10185 815666 dir=left;
10186 }
10187
10188
3/4
✓ Branch 0 taken 2478596 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1292063 times.
✓ Branch 3 taken 1186533 times.
2478596 if(!stunclk && ++clk3>80)
10189 {
10190
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1185487 times.
1186533 if(dmisc1==9) // Breath type
10191 {
10192
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10193 {
10194 563 unsigned r=zc_oldrand();
10195
10196
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10197 {
10198 6 timer=zc_oldrand()%50+50;
10199 6 }
10200 563 }
10201
10202
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10203 {
10204
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10205 {
10206 119 FireBreath(false);
10207 119 }
10208
10209
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10210 {
10211 6 clk3=0;
10212 6 }
10213 489 }
10214 1046 }
10215
10216 else // Not breath type
10217 {
10218 1185487 unsigned r=zc_oldrand();
10219
10220
4/4
✓ Branch 0 taken 18603 times.
✓ Branch 1 taken 1166884 times.
✓ Branch 2 taken 1249 times.
✓ Branch 3 taken 17354 times.
1185487 if(!(r&63) && !HeroInRange(minRange))
10221 {
10222 17354 FireWeapon();
10223
10224
4/4
✓ Branch 0 taken 14852 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17606 if(get_qr(qr_BROKENSTATUES)==0 &&
10225
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14600 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
14852 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10226 {
10227
2/2
✓ Branch 0 taken 13767 times.
✓ Branch 1 taken 899 times.
14666 if(!((r>>7)&15))
10228 {
10229 899 x-=4;
10230 899 FireWeapon();
10231 899 x+=4;
10232 899 }
10233 14666 }
10234
10235 17354 clk3=0;
10236 17354 }
10237 }
10238 1186533 }
10239
10240 2478596 return enemy::animate(index);
10241 2478596 }
10242
10243 2493916 void eProjectile::draw(BITMAP *dest)
10244 {
10245 2493916 update_enemy_frame();
10246 2493916 enemy::draw(dest);
10247 2493916 }
10248
10249 531 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10250 531 {
10251 531 hxofs=1000;
10252 531 }
10253
10254 249609 void eTrigger::draw(BITMAP *dest)
10255 {
10256 249609 update_enemy_frame();
10257 249609 enemy::draw(dest);
10258 249609 }
10259
10260 void eTrigger::death_sfx()
10261 {
10262 //silent death
10263 }
10264
10265 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10266 5 {
10267 5 o_tile+=wpnsbuf[iwNPCs].tile;
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10269 5 SIZEflags = d->SIZEflags;
10270
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10271 5 }
10272
10273 75 bool eNPC::animate(int32_t index)
10274 {
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10276
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10277 70 return Dead(index);
10278
10279
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10280 {
10281 removearmos(x,y,ffcactivated);
10282 }
10283
10284
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10285 {
10286 case 0:
10287 {
10288 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10289 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10290
10291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10292 {
10293 dir=down;
10294 }
10295
10296
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10297 {
10298 5 dir=right;
10299 5 }
10300 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10301 {
10302 dir=up;
10303 }
10304 else
10305 {
10306 dir=left;
10307 }
10308 }
10309 5 break;
10310
10311 case 1:
10312 halting_walk(rate, homing, 0, hrate, 48);
10313
10314 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10315 {
10316 newdir(rate, homing, 0);
10317 clk2=48;
10318 ++misc;
10319 }
10320
10321 if(clk2==0)
10322 misc=0;
10323
10324 break;
10325 }
10326
10327 5 return enemy::animate(index);
10328 75 }
10329
10330 75 void eNPC::draw(BITMAP *dest)
10331 {
10332 75 update_enemy_frame();
10333 75 enemy::draw(dest);
10334 75 }
10335
10336 int32_t eNPC::takehit(weapon*,weapon*)
10337 {
10338 return 0;
10339 }
10340
10341 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10342 94 {
10343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10344 {
10345 94 o_tile=clk;
10346 94 cs=id>>12;
10347 94 }
10348
10349 94 id=id&0xFFF;
10350 94 clk=0;
10351
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10352 94 mainguy=false;
10353 94 SIZEflags = d->SIZEflags;
10354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10355 94 }
10356
10357 81 void eSpinTile::facehero()
10358 {
10359
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10360 {
10361
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10362 1 dir = up;
10363 else
10364 dir = down;
10365 1 }
10366 else
10367 {
10368 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10369 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10370
10371
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10372 {
10373 12 dir=l_down;
10374 12 }
10375
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10376 {
10377 1 dir=down;
10378 1 }
10379
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10380 {
10381 12 dir=r_down;
10382 12 }
10383
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10384 {
10385 6 dir=right;
10386 6 }
10387
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10388 {
10389 17 dir=r_up;
10390 17 }
10391
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10392 {
10393 8 dir=up;
10394 8 }
10395
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10396 {
10397 6 dir=l_up;
10398 6 }
10399 else
10400 {
10401 18 dir=left;
10402 }
10403 }
10404 81 }
10405
10406
10407 15539 bool eSpinTile::animate(int32_t index)
10408 {
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10410
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10411
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10412 {
10413 1152 return Dead(index);
10414 }
10415
10416
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10417 {
10418 1241 removearmos(x,y,ffcactivated);
10419 1241 }
10420
10421 14387 ++misc;
10422
10423
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10424 {
10425 81 facehero();
10426 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10427 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10428 81 angular=true;
10429 81 angle=ddir;
10430 81 step=zslongToFix(dstep*100);
10431 81 }
10432
10433
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10434 52 kickbucket();
10435
10436 14387 sprite::move(step);
10437 14387 return enemy::animate(index);
10438 15539 }
10439
10440 15457 void eSpinTile::draw(BITMAP *dest)
10441 {
10442 15457 update_enemy_frame();
10443 15457 y-=(misc>>4);
10444 15457 yofs+=2;
10445 15457 enemy::draw(dest);
10446 15457 yofs-=2;
10447 15457 y+=(misc>>4);
10448 15457 }
10449
10450 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10451 {
10452 15457 flip = 0;
10453 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10454 15457 yofs+=4;
10455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10456 15457 enemy::drawshadow(dest, translucent);
10457 15457 yofs-=4;
10458 15457 }
10459
10460 2792 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10461 2792 {
10462 //these are here to bypass compiler warnings about unused arguments
10463 2792 Clk=Clk;
10464 2792 mainguy=false;
10465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2792 times.
2792 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10466
1/4
✓ Branch 0 taken 2792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2792 if (SIZEflags != 0) init_size_flags();;
10467 2792 }
10468
10469 627071 void eZora::facehero()
10470 {
10471
2/2
✓ Branch 0 taken 10768 times.
✓ Branch 1 taken 616303 times.
627071 if(Hero.x-x==0)
10472 {
10473 10768 dir=(Hero.y+8<y)?up:down;
10474 10768 }
10475 else
10476 {
10477 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10478 616303 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10479
10480
4/4
✓ Branch 0 taken 124881 times.
✓ Branch 1 taken 491422 times.
✓ Branch 2 taken 46763 times.
✓ Branch 3 taken 78118 times.
616303 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10481 {
10482 78118 dir=l_down;
10483 78118 }
10484
4/4
✓ Branch 0 taken 91766 times.
✓ Branch 1 taken 446419 times.
✓ Branch 2 taken 46763 times.
✓ Branch 3 taken 45003 times.
538185 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10485 {
10486 45003 dir=down;
10487 45003 }
10488
4/4
✓ Branch 0 taken 120912 times.
✓ Branch 1 taken 372270 times.
✓ Branch 2 taken 46763 times.
✓ Branch 3 taken 74149 times.
493182 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10489 {
10490 74149 dir=r_down;
10491 74149 }
10492
4/4
✓ Branch 0 taken 161942 times.
✓ Branch 1 taken 257091 times.
✓ Branch 2 taken 46763 times.
✓ Branch 3 taken 115179 times.
419033 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10493 {
10494 115179 dir=right;
10495 115179 }
10496
4/4
✓ Branch 0 taken 126966 times.
✓ Branch 1 taken 176888 times.
✓ Branch 2 taken 46763 times.
✓ Branch 3 taken 80203 times.
303854 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10497 {
10498 80203 dir=r_up;
10499 80203 }
10500
4/4
✓ Branch 0 taken 88559 times.
✓ Branch 1 taken 135092 times.
✓ Branch 2 taken 46763 times.
✓ Branch 3 taken 41796 times.
223651 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10501 {
10502 41796 dir=up;
10503 41796 }
10504
4/4
✓ Branch 0 taken 121341 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74578 times.
✓ Branch 3 taken 46763 times.
181855 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10505 {
10506 74578 dir=l_up;
10507 74578 }
10508 else
10509 {
10510 107277 dir=left;
10511 }
10512 }
10513 627071 }
10514
10515 855810 bool eZora::animate(int32_t index)
10516 {
10517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 855810 times.
855810 if(switch_hooked) return enemy::animate(index);
10518
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 852956 times.
855810 if(dying)
10519 2854 return Dead(index);
10520
10521
2/2
✓ Branch 0 taken 847219 times.
✓ Branch 1 taken 5737 times.
852956 if(clk==0)
10522 {
10523 5737 removearmos(x,y,ffcactivated);
10524 5737 }
10525
10526
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 852921 times.
852956 if(watch)
10527 {
10528 35 clock_zoras.push_back({screen_spawned, id});
10529 35 return true;
10530 }
10531
10532
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 627071 times.
852921 if(get_qr(qr_NEWENEMYTILES))
10533 {
10534 627071 facehero();
10535 627071 }
10536
10537
6/6
✓ Branch 0 taken 5224 times.
✓ Branch 1 taken 4985 times.
✓ Branch 2 taken 4184 times.
✓ Branch 3 taken 829082 times.
✓ Branch 4 taken 6473 times.
✓ Branch 5 taken 2973 times.
852921 switch(clk)
10538 {
10539 case 0: // reposition him
10540 {
10541 6473 int32_t t=0;
10542 6473 int32_t pos2=zc_oldrand()%160 + 16;
10543 6473 bool placed=false;
10544
10545
4/4
✓ Branch 0 taken 6408 times.
✓ Branch 1 taken 38501 times.
✓ Branch 2 taken 26356 times.
✓ Branch 3 taken 5737 times.
44909 while(!placed && t<160)
10546 {
10547 26356 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10548 90412 auto [sx, sy] = COMBOXY_REGION(rpos);
10549 26356 mapscr* s = get_scr(screen_spawned);
10550
10551 79068 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10552
5/6
✓ Branch 0 taken 6595 times.
✓ Branch 1 taken 19761 times.
✓ Branch 2 taken 6595 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5672 times.
32428 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10553
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6563 times.
6595 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10554
3/4
✓ Branch 0 taken 6563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6072 times.
✓ Branch 3 taken 6040 times.
6595 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10555 {
10556 5672 x=sx;
10557 5672 y=sy;
10558
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5332 times.
5672 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10559 5672 hxofs=1000; // avoid hit detection
10560 5672 stunclk=0;
10561 5672 placed=true;
10562 5672 }
10563
10564 38436 pos2+=19;
10565
10566
2/2
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 4560 times.
38436 if(pos2>=176)
10567 4560 pos2-=160;
10568
10569 38436 ++t;
10570 }
10571
10572
3/4
✓ Branch 0 taken 5672 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5672 times.
5737 if(!placed || whistleclk>=88) // can't place him, he's gone
10573 65 return true;
10574
10575 }
10576 5672 break;
10577
10578 case 35:
10579
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 1361 times.
5224 if(!get_qr(qr_NEWENEMYTILES))
10580 {
10581 1361 dir=(Hero.y+8<y)?up:down;
10582 1361 }
10583
10584 5224 hxofs=0;
10585 5224 break;
10586
10587 case 35+19:
10588 4985 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10589 4985 sfx(wpnsfx(wpn),pan(int32_t(x)));
10590 4985 break;
10591
10592 case 35+66:
10593 4184 hxofs=1000;
10594 4184 break;
10595
10596 case 198:
10597 2973 clk=-1;
10598 2973 break;
10599 }
10600
10601 852120 return enemy::animate(index);
10602 855074 }
10603
10604 865759 void eZora::draw(BITMAP *dest)
10605 {
10606
2/2
✓ Branch 0 taken 19982 times.
✓ Branch 1 taken 845777 times.
865759 if (isSubmerged())
10607 19982 return;
10608
10609 845777 update_enemy_frame();
10610 845777 enemy::draw(dest);
10611 865759 }
10612
10613 865991 bool eZora::isSubmerged() const
10614 {
10615 865991 return clk < 3;
10616 }
10617
10618
3/6
✓ Branch 0 taken 50043 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50043 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50043 times.
✗ Branch 5 not taken.
100086 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10619 50043 {
10620 50043 multishot= timer = fired = dashing = 0;
10621 50043 hashero = false;
10622 50043 dummy_bool[0]=false;
10623
4/8
✓ Branch 0 taken 50043 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50043 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50043 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50043 times.
✗ Branch 7 not taken.
50043 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10624
5/6
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 49046 times.
✓ Branch 2 taken 997 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 517 times.
✓ Branch 5 taken 480 times.
50043 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10625 {
10626
2/4
✓ Branch 0 taken 517 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 517 times.
✗ Branch 3 not taken.
517 step=zslongToFix(dmisc10*100);
10627
10628
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 499 times.
517 if(anim==aARMOS4) o_tile+=20;
10629 517 }
10630
10631
3/4
✓ Branch 0 taken 50043 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 997 times.
✓ Branch 3 taken 49046 times.
50043 if(flags & guy_fade_flicker)
10632 {
10633 997 clk=0;
10634 997 superman = 1;
10635 997 fading=fade_flicker;
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 997 times.
997 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10637 997 dir=down;
10638
10639
4/6
✓ Branch 0 taken 997 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 997 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 438 times.
✓ Branch 5 taken 559 times.
997 if(!canmove(down,(zfix)8,spw_none,false))
10640
3/6
✓ Branch 0 taken 438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 438 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 438 times.
✗ Branch 5 not taken.
438 clk3=int32_t(13.0/step);
10641 997 }
10642
3/4
✓ Branch 0 taken 49046 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48913 times.
✓ Branch 3 taken 133 times.
49046 else if(flags & guy_fade_instant)
10643 {
10644 133 clk=0;
10645 133 }
10646
10647
1/2
✓ Branch 0 taken 50043 times.
✗ Branch 1 not taken.
50043 shadowdistance = 0;
10648 50043 clk4 = clk5 = 0;
10649 //nets+2380;
10650
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50041 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50043 if (SIZEflags != 0) init_size_flags();;
10651 50043 }
10652
10653 15759064 bool eStalfos::animate(int32_t index)
10654 {
10655
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15758808 times.
15759064 if(switch_hooked) return enemy::animate(index);
10656
3/4
✓ Branch 0 taken 15758382 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15758382 times.
15758808 if(fallclk||drownclk)
10657 {
10658 426 return enemy::animate(index);
10659 }
10660
2/2
✓ Branch 0 taken 351706 times.
✓ Branch 1 taken 15406676 times.
15758382 if(dying)
10661 {
10662
2/2
✓ Branch 0 taken 351658 times.
✓ Branch 1 taken 48 times.
351706 if(hashero)
10663 {
10664 48 Hero.setEaten(0);
10665 48 hashero=false;
10666 48 }
10667
10668
10/14
✓ Branch 0 taken 36032 times.
✓ Branch 1 taken 315674 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32347 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
351706 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10669 {
10670 187 hp=-1000;
10671
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10672 187 Ewpns.add(ew);
10673 187 ew->fakez = fakez;
10674
10675
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10676 {
10677 187 ew->step=0;
10678 187 ew->id=wpn;
10679 187 ew->misc=50;
10680 187 ew->clk=48;
10681 187 }
10682
10683 187 fired=true;
10684 187 }
10685
6/6
✓ Branch 0 taken 155416 times.
✓ Branch 1 taken 196103 times.
✓ Branch 2 taken 129378 times.
✓ Branch 3 taken 26038 times.
✓ Branch 4 taken 129360 times.
✓ Branch 5 taken 18 times.
351519 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10686 {
10687
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10688 {
10689 1 int32_t wpn2 = wpn+dmisc3;
10690
10691
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10692 {
10693 wpn2=wpn;
10694 }
10695
10696 1 dummy_bool[0]=true;
10697 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10698 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10699 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10700 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10701 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10702 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10703 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10704 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10705 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10706 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10707 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10708 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10709 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10710 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10711 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10712 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10713 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10714 1 }
10715 18 }
10716
10717 351706 KillWeapon();
10718 351706 return Dead(index);
10719 }
10720 //vire split
10721 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10722 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10723
13/14
✓ Branch 0 taken 21049 times.
✓ Branch 1 taken 15385627 times.
✓ Branch 2 taken 21049 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20698 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14213629 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15406676 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10724 {
10725 1677 stop_bgsfx(index);
10726 1677 int32_t kids = guys.Count();
10727 1677 int32_t id2=dmisc3;
10728
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10729 {
10730
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10731 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10732 3307 }
10733
10734
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10735 {
10736 1 int guycarryingitem = guys.Count()-1;
10737 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10738 1 itemguy = false;
10739 1 }
10740
10741
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10742 {
10743 17 Hero.setEaten(0);
10744 17 hashero=false;
10745 17 }
10746
10747
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10748 323 sfx(deadsfx,pan(int32_t(x)));
10749
10750 1677 return true;
10751 }
10752
10753
2/2
✓ Branch 0 taken 70762 times.
✓ Branch 1 taken 15334237 times.
15404999 if(fading)
10754 {
10755
2/2
✓ Branch 0 taken 1223 times.
✓ Branch 1 taken 69539 times.
70762 if(++clk4 > 60)
10756 {
10757 1223 clk4=0;
10758 1223 superman=0;
10759 1223 fading=0;
10760
10761
4/6
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 962 times.
1223 if(flags&guy_armos && z==0 && fakez == 0)
10762 {
10763 //if a custom size (not 16px by 16px)
10764
10765 //if a custom size (not 16px by 16px)
10766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 if (ffcactivated)
10767 removearmosffc(*ffcactivated);
10768 else
10769 {
10770
4/8
✓ Branch 0 taken 962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 962 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 962 times.
962 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10771 {
10772 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10773 for(int32_t dx = 0; dx < tysz; dx ++)
10774 {
10775 for(int32_t dy = 0; dy < tysz; dy++)
10776 {
10777 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10778 did_armos = false;
10779 }
10780 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10781 did_armos = false;
10782 }
10783 for(int32_t dy = 0; dy < tysz; dy ++)
10784 {
10785 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10786 did_armos = false;
10787 }
10788 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10789 }
10790 962 else removearmos(x,y);
10791 }
10792
10793 962 }
10794
10795 1223 clk2=0;
10796
10797 1223 newdir();
10798 1223 }
10799 69539 else return enemy::animate(index);
10800 1223 }
10801
6/8
✓ Branch 0 taken 147444 times.
✓ Branch 1 taken 15186793 times.
✓ Branch 2 taken 147444 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147444 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 137951 times.
✓ Branch 7 taken 9493 times.
15334237 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10802 9493 removearmos(x,y,ffcactivated);
10803
10804
10805
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15328253 times.
15335460 if(hashero)
10806 {
10807 7207 Hero.setX(x);
10808 7207 Hero.setY(y);
10809 7207 ++clk2;
10810
10811
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10812 {
10813
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10814 {
10815 case e7tEATITEMS:
10816 {
10817
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10818 {
10819
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10820 22 game->set_item(i, false);
10821 5632 }
10822
10823 22 break;
10824 }
10825
10826 case e7tEATMAGIC:
10827 game->change_dmagic(-1*game->get_magicdrainrate());
10828 break;
10829
10830 case e7tEATRUPEES:
10831 game->change_drupy(-1);
10832 break;
10833 }
10834
10835 899 clk2=0;
10836 899 }
10837
10838
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10839 6661 --clk;
10840 7207 }
10841
4/4
✓ Branch 0 taken 1048661 times.
✓ Branch 1 taken 14279592 times.
✓ Branch 2 taken 615892 times.
✓ Branch 3 taken 432769 times.
15328253 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10842 {
10843 // Movement engine
10844
6/6
✓ Branch 0 taken 836338 times.
✓ Branch 1 taken 14059146 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14055685 times.
✓ Branch 5 taken 59 times.
14895484 if(clk>=0) switch(id>>12)
10845 {
10846 case 0: // Normal movement
10847
10848 /*
10849 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10850 {
10851 // Overloading clk4 (Tribble clock) here...
10852 step=17/100.0;
10853 if(clk4<32) misc=1;
10854 else if(clk4<48) misc=2;
10855 else if(clk4<300) { misc=3; step = dstep/100.0; }
10856 else if(clk4<316) misc=2;
10857 else if(clk4<412) misc=1;
10858 else if(clk4<540) { misc=0; step=0; }
10859 else clk4=0;
10860 if(clk4==48) clk=0;
10861 hxofs=(misc>=2)?0:1000;
10862 if (dmisc9==e9tLEEVER)
10863 variable_walk(rate, homing, 0);
10864 else
10865 variable_walk_8(rate, homing, 4, 0);
10866 break;
10867 }
10868 */
10869
4/4
✓ Branch 0 taken 13676651 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13259575 times.
14055685 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10870 {
10871 796110 vire_hop();
10872 796110 break;
10873 }
10874
2/2
✓ Branch 0 taken 984687 times.
✓ Branch 1 taken 12274888 times.
13259575 else if(dmisc9==e9tROPE) //Rope charge
10875 {
10876
9/10
✓ Branch 0 taken 967265 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138779 times.
✓ Branch 3 taken 828486 times.
✓ Branch 4 taken 126694 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125869 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125869 times.
984687 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10877 {
10878
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116793 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125869 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10879 {
10880
10881
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10882 {
10883 14 hp=-1000;
10884
10885
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10886 {
10887
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10888 14 Ewpns.add(ew);
10889 14 ew->fakez = fakez;
10890
10891
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10892 {
10893 14 ew->step=0;
10894 14 ew->id=wpn+dmisc3;
10895 14 ew->misc=50;
10896 14 ew->clk=48;
10897 14 }
10898
10899 14 fired=true;
10900 14 }
10901 else
10902 {
10903 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10904 Ewpns.add(ew);
10905 ew->fakez = fakez;
10906
10907 if(wpn==ewSBomb || wpn==ewBomb)
10908 {
10909 ew->step=0;
10910 ew->id=wpn;
10911 ew->misc=50;
10912 ew->clk=48;
10913 }
10914
10915 fired=true;
10916 }
10917 14 }
10918
10919 else
10920 {
10921 33 hp=-1000;
10922
10923 int32_t wpn2;
10924
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10925 33 wpn2=wpn;
10926 else
10927 wpn2=wpn;
10928
10929
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10930 33 Ewpns.add(ew);
10931 33 ew->fakez = fakez;
10932
10933
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10934 {
10935 33 ew->step=0;
10936 33 ew->id=wpn2;
10937 33 ew->misc=50;
10938 33 ew->clk=48;
10939 33 }
10940
10941 33 fired=true;
10942 }
10943 47 }
10944 125869 }
10945
10946 984687 charge_attack();
10947 984687 break;
10948 }
10949 /*
10950 * Boomerang-throwers have a halt count of 1
10951 * Zols have a halt count of (zc_oldrand()&7)<<4
10952 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10953 * Everything else has 48
10954 */
10955 else
10956 {
10957
2/2
✓ Branch 0 taken 568304 times.
✓ Branch 1 taken 11706584 times.
12274888 if(wpn==ewBrang) // Goriya
10958 {
10959 568304 halting_walk(rate,homing,0,hrate, 1);
10960 568304 }
10961
4/4
✓ Branch 0 taken 11558178 times.
✓ Branch 1 taken 148406 times.
✓ Branch 2 taken 4525770 times.
✓ Branch 3 taken 7032408 times.
11706584 else if(dmisc9==e9tNORMAL && wpn==0)
10962 {
10963
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6314435 times.
7032408 if(dmisc2==e2tSPLITHIT) // Zol
10964 {
10965 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10966 717973 }
10967
4/4
✓ Branch 0 taken 1730967 times.
✓ Branch 1 taken 4583468 times.
✓ Branch 2 taken 1515076 times.
✓ Branch 3 taken 215891 times.
6314435 else if(frate<=8 && starting_hp==1) // Gel
10968 {
10969 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10970 215891 }
10971 else // Other
10972 {
10973 6098544 halting_walk(rate,homing,0,hrate, 48);
10974 }
10975 7032408 }
10976 else // Other
10977 {
10978 4674176 halting_walk(rate,homing,0,hrate, 48);
10979 }
10980 }
10981
10982 //if not in midair, and Hero's swinging sword is nearby, jump.
10983 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10984 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10985 {
10986 facehero(false);
10987 sclk=16+((dir^1)<<8);
10988 fall=-FEATHERJUMP;
10989 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10990 }*/
10991 12274888 break;
10992
10993 // Following cases are for just after creation-by-splitting.
10994 case 1:
10995
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10996 {
10997 821 dir=up;
10998 821 step=8;
10999 821 }
11000
11001
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
11002 {
11003 2504 move(step);
11004
11005
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11006 512 dir=down;
11007 2504 }
11008
11009
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11010 {
11011
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11012 503 x+=16;
11013 790 }
11014
11015 3294 ++misc;
11016 3294 break;
11017
11018 case 2:
11019
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11020 {
11021 15 dir=down;
11022 15 step=8;
11023 15 }
11024
11025
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11026 {
11027 45 move(step);
11028 /*
11029 if(!canmove(dir,(zfix)0,0,false))
11030 dir=up;
11031 */
11032 45 }
11033
11034
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11035 {
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11037 14 x-=16;
11038 14 }
11039
11040 59 ++misc;
11041 59 break;
11042
11043 default:
11044
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11045 {
11046 28 dir=(zc_oldrand()%4);
11047 28 step=8;
11048 28 }
11049
11050
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11051 {
11052 83 move(step);
11053
11054
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11055 2 dir=dir^1;
11056 83 }
11057
11058
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11059 {
11060
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11061 8 x+=(dir==left ? -16 : 16);
11062 25 }
11063
11064 108 ++misc;
11065 108 break;
11066 14059146 }
11067
11068
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14870212 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14895484 if(id>>12 && misc>=4) //recently spawned by a split enemy
11069 {
11070 829 id&=0xFFF;
11071 829 step = zslongToFix(dstep*100);
11072
11073
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11074
11075
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>world_w-48) x=world_w-48;
11076
11077
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11078
11079
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>world_h-48) y=world_h-48;
11080
11081 829 misc=3;
11082 829 }
11083 14895484 }
11084 else
11085 {
11086 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11087
1/2
✓ Branch 0 taken 432769 times.
✗ Branch 1 not taken.
432769 if(clk2>2) clk2--;
11088 }
11089
11090 // Fire Zol
11091
8/8
✓ Branch 0 taken 6076400 times.
✓ Branch 1 taken 9259060 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5937119 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15335460 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11092 {
11093 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11094 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11095
11096 1102 int32_t i=Ewpns.Count()-1;
11097 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11098
11099
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11100 {
11101 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11102 if ( ew->do_animation ) ew->tile+=ew->aframe;
11103 }
11104 1102 }
11105 // Goriya
11106
14/16
✓ Branch 0 taken 1048661 times.
✓ Branch 1 taken 14285697 times.
✓ Branch 2 taken 468465 times.
✓ Branch 3 taken 580196 times.
✓ Branch 4 taken 456166 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423189 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423189 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420448 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420448 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414088 times.
✓ Branch 15 taken 6360 times.
15334358 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11107 {
11108 6360 misc=index+100;
11109
7/14
✓ Branch 0 taken 6360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6360 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6360 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6360 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6360 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6360 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6360 times.
✗ Branch 13 not taken.
6360 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11110 6360 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11111
11112
2/2
✓ Branch 0 taken 6103 times.
✓ Branch 1 taken 257 times.
6360 if(dmisc1==2)
11113 {
11114 257 int32_t ndir=dir;
11115
11116
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11117 {
11118 6 ndir=(Hero.y+8<y)?up:down;
11119 6 }
11120 else //turn to face Hero
11121 {
11122 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11123 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11124
11125
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11126 {
11127 13 ndir=down;
11128 13 }
11129
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11130 {
11131 68 ndir=right;
11132 68 }
11133
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11134 {
11135 48 ndir=up;
11136 48 }
11137 else
11138 {
11139 122 ndir=left;
11140 }
11141 }
11142
11143 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11144
11145
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11146 {
11147 223 dir=ndir;
11148 223 }
11149 257 }
11150 6360 }
11151
15/16
✓ Branch 0 taken 15269375 times.
✓ Branch 1 taken 58623 times.
✓ Branch 2 taken 220935 times.
✓ Branch 3 taken 15107063 times.
✓ Branch 4 taken 194817 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 169925 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168541 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153547 times.
✓ Branch 11 taken 14994 times.
✓ Branch 12 taken 153547 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152603 times.
15327998 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11152
3/3
✓ Branch 0 taken 25965 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152603 switch(dmisc1)
11153 {
11154 case e1tCONSTANT: //Deathnut
11155 {
11156 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11157
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11158 {
11159 2583 clk5=0;
11160 2583 fired=false;
11161 2583 }
11162
11163 125732 clk5+=(zc_oldrand()&3);
11164
11165
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11166 {
11167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11168
11169
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11170 {
11171
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11172 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11173 2827 sfx(wpnsfx(wpn),pan(int32_t(x)));
11174 2827 fired=true;
11175 2827 }
11176 51069 }
11177
11178 125732 break;
11179 }
11180
11181 case e1tFIREOCTO: //Fire Octo
11182 906 timer=zc_oldrand()%50+50;
11183 906 break;
11184
11185 default:
11186 25965 FireWeapon();
11187 25965 break;
11188 152603 }
11189
11190 /* Fire again if:
11191 * - clk2 about to run out
11192 * - not already double-firing (dmisc1 is 1)
11193 * - not carrying Hero
11194 * - one in 0xF chance
11195 */
11196
8/10
✓ Branch 0 taken 524719 times.
✓ Branch 1 taken 14810741 times.
✓ Branch 2 taken 3941 times.
✓ Branch 3 taken 520778 times.
✓ Branch 4 taken 3941 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3941 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3690 times.
✓ Branch 9 taken 251 times.
15335460 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11197 {
11198 #if 1
11199 251 newdir(rate, homing, grumble);
11200 #else
11201 dir^=2;
11202 #endif
11203 251 clk2=28;
11204 251 ++multishot;
11205 251 }
11206
11207
2/2
✓ Branch 0 taken 3483997 times.
✓ Branch 1 taken 11851463 times.
15335460 if(clk2==0)
11208 {
11209 11851463 multishot = 0;
11210 11851463 }
11211
11212
2/2
✓ Branch 0 taken 15271150 times.
✓ Branch 1 taken 64310 times.
15335460 if(timer) //Fire Octo
11213 {
11214 64310 clk2=15; //this keeps the octo in place until he's done firing
11215
11216
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11217 {
11218 15752 FireBreath(false);
11219 15752 }
11220
11221 64310 --timer;
11222 64310 }
11223
11224
2/2
✓ Branch 0 taken 15086067 times.
✓ Branch 1 taken 249393 times.
15335460 if(dmisc2==e2tTRIBBLE)
11225 249393 ++clk4;
11226
11227
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15330980 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15334767 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15335460 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11228 {
11229 693 int32_t kids = guys.Count();
11230 693 int32_t id2=dmisc3;
11231
11232
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11233 {
11234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11235 {
11236
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11237 {
11238 int guycarryingitem = guys.Count()-1;
11239 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11240 itemguy = false;
11241 }
11242
11243 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11244 693 }
11245 693 }
11246
11247
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11248 {
11249 Hero.setEaten(0);
11250 hashero=false;
11251 }
11252
11253 693 stop_bgsfx(index);
11254 693 return true;
11255 }
11256
11257 15334767 return enemy::animate(index);
11258 15759064 }
11259
11260 16181078 void eStalfos::draw(BITMAP *dest)
11261 {
11262 16181078 update_enemy_frame();
11263
11264
7/8
✓ Branch 0 taken 16180652 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16180652 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16093701 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16181078 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11265 {
11266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11267 11115 }
11268
11269 16181078 enemy::draw(dest);
11270 16181078 }
11271
11272 7472126 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11273 {
11274 7472126 int32_t tempy=yofs;
11275
11276
4/4
✓ Branch 0 taken 7256708 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7160507 times.
✓ Branch 3 taken 311619 times.
7472126 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11277 {
11278 311619 flip = 0;
11279 311619 int32_t fdiv = frate/4;
11280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11281
11282
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11283 311619 efrate:((clk>=(frate>>1))?1:0);
11284 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11285
11286
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11287 {
11288 311619 shadowtile+=f2;
11289 311619 }
11290 else
11291 {
11292 shadowtile+=f2?1:0;
11293 }
11294
11295 311619 yofs+=shadowdistance;
11296 311619 yofs+=8;
11297 311619 }
11298
4/4
✓ Branch 0 taken 7256708 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7469091 times.
✓ Branch 3 taken 3035 times.
7472126 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11299 {
11300 3035 flip = 0;
11301 3035 int32_t fdiv = frate/4;
11302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11303
11304
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11305 3035 efrate:((clk>=(frate>>1))?1:0);
11306 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11307
11308
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11309 {
11310 3035 shadowtile+=f2;
11311 3035 }
11312 else
11313 {
11314 shadowtile+=f2?1:0;
11315 }
11316 3035 }
11317
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7466630 times.
7472126 if(!shadow_overpit(this))
11318 7466630 enemy::drawshadow(dest, translucent);
11319 7472126 yofs=tempy;
11320 7472126 }
11321
11322 157435 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11323 {
11324 157435 int32_t wpnId = w->id;
11325 157435 int32_t wpnDir = w->dir;
11326
11327
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156017 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157435 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11328
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11329
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11330 {
11331 265 shield = false;
11332 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11333
11334
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11335 243 o_tile=s_tile;
11336 265 }
11337
11338 157435 int32_t ret = enemy::takehit(w,realweap);
11339
11340
4/4
✓ Branch 0 taken 22226 times.
✓ Branch 1 taken 135209 times.
✓ Branch 2 taken 20475 times.
✓ Branch 3 taken 1751 times.
157435 if(sclk && dmisc2==e2tSPLITHIT)
11341 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11342
11343 157435 return ret;
11344 }
11345
11346 984687 void eStalfos::charge_attack()
11347 {
11348
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 977972 times.
984687 if(slide())
11349 6715 return;
11350
11351
10/12
✓ Branch 0 taken 977972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975568 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 946055 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 924502 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 918879 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 918879 times.
977972 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11352 59093 return;
11353
11354
2/2
✓ Branch 0 taken 37515 times.
✓ Branch 1 taken 881364 times.
918879 if(clk3<=0)
11355 {
11356 37515 fix_coords(true);
11357
11358
2/2
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 27472 times.
37515 if(!dashing)
11359 {
11360 27472 int32_t ldir = lined_up(7,false);
11361
11362
4/4
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 24365 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 2651 times.
27472 if(ldir!=-1 && canmove(ldir,false))
11363 {
11364 2651 dir=ldir;
11365 2651 dashing=true;
11366
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2651 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11367 2651 step=zslongToFix(dstep*100)+1;
11368 else
11369 step=zslongToFix(dmisc10*100);
11370 2651 }
11371 24821 else newdir(4,0,0);
11372 27472 }
11373
11374
2/2
✓ Branch 0 taken 36061 times.
✓ Branch 1 taken 1454 times.
37515 if(!canmove(dir,false))
11375 {
11376 1454 step=zslongToFix(dstep*100);
11377 1454 newdir();
11378 1454 dashing=false;
11379 1454 }
11380
11381 37515 zfix div = step;
11382
11383
1/2
✓ Branch 0 taken 37515 times.
✗ Branch 1 not taken.
37515 if(div == 0)
11384 div = 1;
11385
11386 37515 clk3=(int32_t)(16.0/div);
11387 37515 return;
11388 }
11389
11390 881364 move(step);
11391 881364 --clk3;
11392 984687 }
11393
11394 796110 void eStalfos::vire_hop()
11395 {
11396
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11397 {
11398
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11399 {
11400
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11401 3843 }
11402 376292 }
11403 417076 else sclk=0;
11404
11405
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11406 31892 return;
11407
11408 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11409 int32_t jump_height;
11410
11411
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11412 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11413 else jump_height = dmisc10;
11414
11415 761476 y=floor_y;
11416
11417
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11418 {
11419 26258 fix_coords();
11420
11421 //z=0;
11422 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11423 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11424
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11425 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11426
11427
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11428 {
11429 //z=0;
11430
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11431 {
11432
11433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11434 17258 }
11435 21336 }
11436
11437
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11438 {
11439 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11440 7030 }
11441
11442 26258 clk3=int32_t(16.0/step.getFloat());
11443 26258 }
11444
11445 761476 --clk3;
11446
11447
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11448 761476 move(step);
11449
11450 761476 floor_y=y;
11451 761476 clk2--;
11452
11453 //if we're in the middle of a jump
11454
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11455 {
11456 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11457
11458
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11459 {
11460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11461 93147 else z=h;
11462 93147 }
11463 else
11464 {
11465 384731 y=floor_y-h;
11466 384731 shadowdistance=h;
11467 }
11468 477878 }
11469 else
11470 283598 shadowdistance = 0;
11471 796110 }
11472
11473 138 void eStalfos::eathero()
11474 {
11475
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11476 {
11477 70 hashero=true;
11478 70 y=floor_y;
11479 70 z=0;
11480
11481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11482 {
11483 Hero.setX(x);
11484 Hero.setY(y);
11485 }
11486 else
11487 {
11488 70 x=Hero.getX();
11489 70 y=Hero.getY();
11490 }
11491
11492 70 clk2=0;
11493 70 }
11494 138 }
11495
11496 1469109 bool eStalfos::WeaponOut()
11497 {
11498
2/2
✓ Branch 0 taken 2400445 times.
✓ Branch 1 taken 622252 times.
3022697 for(int32_t i=0; i<Ewpns.Count(); i++)
11499 {
11500
3/4
✓ Branch 0 taken 846857 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846857 times.
✗ Branch 3 not taken.
2400445 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11501 {
11502 846857 return true;
11503 }
11504 1553588 }
11505
11506 622252 return false;
11507 1469109 }
11508
11509 351706 void eStalfos::KillWeapon()
11510 {
11511
2/2
✓ Branch 0 taken 292009 times.
✓ Branch 1 taken 351706 times.
643715 for(int32_t i=0; i<Ewpns.Count(); i++)
11512 {
11513
4/4
✓ Branch 0 taken 243911 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 243101 times.
✓ Branch 3 taken 810 times.
292009 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11514 {
11515 //only kill this Goriya's boomerang -DD
11516
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11517 {
11518 411 Ewpns.del(i);
11519 411 }
11520 810 }
11521 292009 }
11522 351706 }
11523
11524 void eStalfos::break_shield()
11525 {
11526 if(!shield)
11527 return;
11528
11529 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11530 shield=false;
11531
11532 if(get_qr(qr_BRKNSHLDTILES))
11533 o_tile=s_tile;
11534 }
11535
11536 void eStalfos::repair_shield()
11537 {
11538 if (shield)
11539 return;
11540
11541 shield = true;
11542
11543 if (get_qr(qr_BRKNSHLDTILES))
11544 {
11545 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11546 else o_tile = d->tile;
11547 }
11548 }
11549
11550 13665 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11551 13665 {
11552
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 dir=(zc_oldrand()&7)+8;
11553
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 step=0;
11554 13665 movestatus=1;
11555
3/4
✓ Branch 0 taken 10541 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10541 times.
13665 if (dmisc1 != 1 && dmisc19 > 0)
11556 {
11557 step = dmisc19/100.0;
11558 movestatus = 1;
11559 }
11560
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 if (dmisc1 == 2) movestatus=2;
11561 13665 c=0;
11562 13665 clk4=0;
11563 //nets;
11564
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 init_size_flags();
11565 13665 dummy_int[1]=0;
11566 13665 }
11567
11568 3520203 bool eKeese::animate(int32_t index)
11569 {
11570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3520203 times.
3520203 if(switch_hooked) return enemy::animate(index);
11571
2/4
✓ Branch 0 taken 3520203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3520203 times.
3520203 if(fallclk||drownclk) return enemy::animate(index);
11572
2/2
✓ Branch 0 taken 124327 times.
✓ Branch 1 taken 3395876 times.
3520203 if(dying)
11573 124327 return Dead(index);
11574
11575
2/2
✓ Branch 0 taken 3369770 times.
✓ Branch 1 taken 26106 times.
3395876 if(clk==0)
11576 {
11577 26106 removearmos(x,y,ffcactivated);
11578 26106 }
11579
11580
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2370834 times.
3395876 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11581 {
11582 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11583 1025042 }
11584 else
11585 {
11586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2370834 times.
2370834 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11587 2370834 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11588 }
11589
11590
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3275538 times.
3395876 if(dmisc2 == e2tKEESETRIB)
11591 {
11592
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11593 {
11594
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11595 {
11596 105 int32_t kids = guys.Count();
11597 105 bool success = false;
11598 105 int32_t id2=dmisc3;
11599 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11600
11601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11602 {
11603
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11604 {
11605 int guycarryingitem = guys.Count()-1;
11606 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11607 itemguy = false;
11608 }
11609
11610 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11611 105 }
11612
11613 105 stop_bgsfx(index);
11614 105 return true;
11615 }
11616 else
11617 {
11618 86 clk4=0;
11619 }
11620 86 }
11621 120233 }
11622 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11623
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2429659 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3275538 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11624 {
11625
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11626 {
11627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11628 {
11629 fakez=int32_t(step/zslongToFix(dstep*100));
11630 // Some variance in keese flight heights when away from Hero
11631 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11632
11633 }
11634 else
11635 {
11636 687068 z=int32_t(step/zslongToFix(dstep*100));
11637 // Some variance in keese flight heights when away from Hero
11638
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11639 }
11640 687068 }
11641 else
11642 {
11643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11644 {
11645 fakez=int32_t(step/zslongToFix(dstep*100));
11646 // Some variance in keese flight heights when away from Hero
11647 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11648
11649 }
11650 else
11651 {
11652 158811 z=int32_t(step/zslongToFix(dstep*100));
11653 // Some variance in keese flight heights when away from Hero
11654
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11655 }
11656 }
11657 845879 }
11658
11659 3395771 return enemy::animate(index);
11660 3520203 }
11661
11662 2072493 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11663 {
11664 2072493 int32_t tempy=yofs;
11665 2072493 flip = 0;
11666 2072493 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11667
11668
2/2
✓ Branch 0 taken 661031 times.
✓ Branch 1 taken 1411462 times.
2072493 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11669
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1381930 times.
2072493 if(!get_qr(qr_ENEMIESZAXIS))
11670 {
11671 1381930 yofs+=int32_t(step/zslongToFix(dstep*10));
11672 1381930 }
11673
11674
6/6
✓ Branch 0 taken 2051803 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1374983 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2072493 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11675 2036435 enemy::drawshadow(dest, translucent);
11676 2072493 yofs=tempy;
11677 2072493 }
11678
11679 7918287 void eKeese::draw(BITMAP *dest)
11680 {
11681 7918287 update_enemy_frame();
11682 7918287 enemy::draw(dest);
11683 7918287 }
11684
11685 13665 void eKeese::init_size_flags()
11686 {
11687 13665 SIZEflags = d->SIZEflags;
11688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
13665 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11689
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11690
11691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
13665 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13665 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11693
11694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
13665 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11695
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11696
11697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
13665 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13665 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11699
11700
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13665 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11701 // al_trace("Enemy txsz:%i\n", txsz);
11702
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13665 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11703
11704
11705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13665 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11706
11707
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11708
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11709 {
11710 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11711 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11712 }
11713
11714
1/2
✓ Branch 0 taken 13665 times.
✗ Branch 1 not taken.
13665 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11715 13665 }
11716
11717 20165 void eWizzrobe::submerge(bool set)
11718 {
11719
2/2
✓ Branch 0 taken 20018 times.
✓ Branch 1 taken 147 times.
20165 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11720 {
11721 20018 hxofs = set?1000:0;
11722 20018 return;
11723 }
11724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11725 147 submerged = set;
11726
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11727 76 hxofs+=1000;
11728 71 else hxofs -= 1000;
11729 20165 }
11730 5292 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11731 5292 {
11732 5292 hxofs = 0;
11733 5292 submerged = false;
11734
2/2
✓ Branch 0 taken 2302 times.
✓ Branch 1 taken 2990 times.
5292 switch(dmisc1)
11735 {
11736 case 0:
11737 2990 submerge(true);
11738 2990 fading=fade_invisible;
11739 // Set clk to just before the 'reappear' threshold
11740
9/10
✓ Branch 0 taken 2989 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2989 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1806 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1805 times.
✓ Branch 9 taken 1 times.
2990 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11741 2990 break;
11742
11743 default:
11744 2302 dir=(loadside==right)?right:left;
11745 2302 misc=-3;
11746 2302 break;
11747 }
11748
11749 //netst+2880;
11750 5292 charging=false;
11751 5292 firing=false;
11752 5292 fclk=0;
11753
2/2
✓ Branch 0 taken 2302 times.
✓ Branch 1 taken 2990 times.
5292 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11754
1/4
✓ Branch 0 taken 5292 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5292 if (SIZEflags != 0) init_size_flags();;
11755 5292 }
11756
11757 2061732 bool eWizzrobe::animate(int32_t index)
11758 {
11759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2061732 times.
2061732 if(switch_hooked) return enemy::animate(index);
11760
2/4
✓ Branch 0 taken 2061732 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2061732 times.
2061732 if(fallclk||drownclk) return enemy::animate(index);
11761
2/2
✓ Branch 0 taken 37855 times.
✓ Branch 1 taken 2023877 times.
2061732 if(dying)
11762 {
11763 37855 return Dead(index);
11764 }
11765
11766
2/2
✓ Branch 0 taken 1958422 times.
✓ Branch 1 taken 65455 times.
2023877 if(clk==0)
11767 {
11768 65455 removearmos(x,y,ffcactivated);
11769 65455 }
11770
11771
2/2
✓ Branch 0 taken 999831 times.
✓ Branch 1 taken 1024046 times.
2023877 if(dmisc1) // Floating
11772 {
11773 999831 wizzrobe_attack();
11774 999831 }
11775 else // Teleporting
11776 {
11777
5/6
✓ Branch 0 taken 1016962 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1005875 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024046 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11778 {
11779 7084 fading=0;
11780 7084 submerge(false);
11781 7084 solid_update(false);
11782 7084 }
11783
8/8
✓ Branch 0 taken 983055 times.
✓ Branch 1 taken 6238 times.
✓ Branch 2 taken 5311 times.
✓ Branch 3 taken 5149 times.
✓ Branch 4 taken 5004 times.
✓ Branch 5 taken 4245 times.
✓ Branch 6 taken 4107 times.
✓ Branch 7 taken 3853 times.
1016962 else switch(clk)
11784 {
11785 case 0:
11786
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5121 times.
6238 if(!dmisc2)
11787 {
11788 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11789 // but should not appear on dungeon walls.
11790
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4708 times.
5121 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11791
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4484 times.
4708 else if (editorflags&ENEMY_FLAG5)
11792 {
11793 //2.10 Windrobe
11794 //randomise location and face Hero
11795 224 int32_t t=0;
11796 224 bool placed=false;
11797
11798
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11799 {
11800
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11801 {
11802 280 x=((zc_oldrand()%12)+2)*16;
11803 280 y=((zc_oldrand()%7)+2)*16;
11804 280 }
11805 else
11806 {
11807 87 x=((zc_oldrand()%14)+1)*16;
11808 87 y=((zc_oldrand()%9)+1)*16;
11809 }
11810
11811 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11812
11813
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11814 {
11815 224 placed=true;
11816 224 }
11817
11818 367 ++t;
11819 }
11820
11821
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11822 {
11823
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11824 {
11825 47 dir=down;
11826 47 }
11827 else
11828 {
11829 14 dir=up;
11830 }
11831 61 }
11832 else
11833 {
11834
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11835 {
11836 72 dir=right;
11837 72 }
11838 else
11839 {
11840 91 dir=left;
11841 }
11842 }
11843
11844
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11845 return true;
11846
11847
11848 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11849 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11850 224 }
11851 4484 else place_on_axis(true, dmisc4!=0);
11852 5121 }
11853 else
11854 {
11855 1117 int32_t t=0;
11856 1117 bool placed=false;
11857
11858
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11859 {
11860
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11861 {
11862 1340 x=((zc_oldrand()%12)+2)*16;
11863 1340 y=((zc_oldrand()%7)+2)*16;
11864 1340 }
11865 else
11866 {
11867 1103 x=((zc_oldrand()%14)+1)*16;
11868 1103 y=((zc_oldrand()%9)+1)*16;
11869 }
11870
11871 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11872
11873
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11874 {
11875 1117 placed=true;
11876 1117 }
11877
11878 2443 ++t;
11879 }
11880
11881
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11882 {
11883
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11884 {
11885 238 dir=down;
11886 238 }
11887 else
11888 {
11889 148 dir=up;
11890 }
11891 386 }
11892 else
11893 {
11894
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11895 {
11896 340 dir=right;
11897 340 }
11898 else
11899 {
11900 391 dir=left;
11901 }
11902 }
11903
11904
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11905 return true;
11906 }
11907
11908 6238 fading=fade_flicker;
11909 6238 submerge(false);
11910 6238 solid_update(false);
11911 6238 break;
11912
11913 case 64:
11914 5311 fading=0;
11915 5311 charging=true;
11916 5311 break;
11917
11918 case 73:
11919 5149 charging=false;
11920 5149 firing=40;
11921 5149 break;
11922
11923 case 83:
11924 5004 wizzrobe_attack_for_real();
11925 5004 break;
11926
11927 case 119:
11928 4245 firing=false;
11929 4245 charging=true;
11930 4245 break;
11931
11932 case 128:
11933 4107 fading=fade_flicker;
11934 4107 charging=false;
11935 4107 break;
11936
11937 case 146:
11938 3853 fading=fade_invisible;
11939 3853 submerge(true);
11940 3853 solid_update(false);
11941
11942 [[fallthrough]];
11943 default:
11944
4/4
✓ Branch 0 taken 986748 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980661 times.
✓ Branch 3 taken 6247 times.
986908 if(clk>=(146+zc_max(0,dmisc5)))
11945 6247 clk=-1;
11946
11947 986908 break;
11948 }
11949 }
11950
11951 2023877 return enemy::animate(index);
11952 2061732 }
11953
11954 7884 void eWizzrobe::wizzrobe_attack_for_real()
11955 {
11956
1/2
✓ Branch 0 taken 7884 times.
✗ Branch 1 not taken.
7884 if(wpn==0) // Edited enemies
11957 return;
11958
11959
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 5919 times.
7884 if(dmisc2 == 0) //normal weapon
11960 {
11961 5919 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11962 5919 sfx(firesfx, pan(int32_t(x)));
11963 5919 }
11964
2/2
✓ Branch 0 taken 977 times.
✓ Branch 1 taken 988 times.
1965 else if(dmisc2 == 1) // ring of fire
11965 {
11966 977 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11967 977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11968 977 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11969 977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11970 977 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11971 977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11972 977 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11973 977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11974 977 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11975 977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11976 977 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11977 977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11978 977 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11979 977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11980 977 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11981 977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11982 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11983 //i've compromised by making all old quest use this code chunk by default.
11984
1/2
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
977 if (FFCore.quest_format[vGuys] < 51)
11985 {
11986 977 sfx(WAV_FIRE, pan(int32_t(x)));
11987
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 507 times.
977 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(int32_t(x)));
11988 else
11989 {
11990
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11991 {
11992 19 case ewFireball: sfx(40, pan(int32_t(x))); break;
11993 case ewBrang: sfx(4, pan(int32_t(x))); break; //Ghost.zh has 0?
11994 case ewSword: sfx(20, pan(int32_t(x))); break; //Ghost.zh has 0?
11995 case ewRock: sfx(51, pan(int32_t(x))); break;
11996 68 case ewMagic: sfx(32, pan(int32_t(x))); break;
11997 case ewBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
11998 case ewSBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
11999 case ewLitBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12000 case ewLitSBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12001 case ewFireTrail: sfx(13, pan(int32_t(x))); break;
12002 420 case ewFlame: sfx(13, pan(int32_t(x))); break;
12003 case ewWind: sfx(32, pan(int32_t(x))); break;
12004 case ewFlame2: sfx(13, pan(int32_t(x))); break;
12005 case ewFlame2Trail: sfx(13, pan(int32_t(x))); break;
12006 case ewIce: sfx(44, pan(int32_t(x))); break;
12007 case ewFireball2: sfx(40, pan(int32_t(x))); break; //fireball (rising)
12008 default: sfx(WAV_FIRE, pan(int32_t(x))); break;
12009 }
12010 }
12011 977 }
12012 else
12013 {
12014 sfx(firesfx, pan(int32_t(x)));
12015 }
12016 977 }
12017
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12018 {
12019 971 int32_t bc=0;
12020
12021
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12022 {
12023
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12024 {
12025 5195 ++bc;
12026 5195 }
12027 10497 }
12028
12029
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12030 {
12031 963 int32_t kids = guys.Count();
12032 963 int32_t bats=(zc_oldrand()%3)+1;
12033
12034
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12035 {
12036 // Summon bats (or anything)
12037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12038 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12039 1965 }
12040 963 sfx(firesfx, pan(int32_t(x)));
12041 963 }
12042 971 }
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12044 {
12045
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12046 {
12047 return;
12048 }
12049
12050 17 int32_t kids = guys.Count();
12051
12052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12053 {
12054 17 int32_t newguys=(zc_oldrand()%3)+1;
12055 17 bool summoned=false;
12056
12057
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12058 {
12059 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12060 32 int32_t x2=0;
12061 32 int32_t y2=0;
12062
12063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12064 {
12065 36 x2=16*((zc_oldrand()%12)+2);
12066 36 y2=16*((zc_oldrand()%7)+2);
12067
12068
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12069 {
12070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12071 {
12072 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12073
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12074 {
12075 ((enemy*)guys.spr(kids+i))->fakez = 64;
12076 ((enemy*)guys.spr(kids+i))->z = 0;
12077 }
12078 32 }
12079
12080 32 summoned=true;
12081 32 break;
12082 }
12083 4 }
12084 32 }
12085
12086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12087 {
12088 17 sfx(firesfx, pan(int32_t(x)));
12089 17 }
12090 17 }
12091 17 }
12092 7884 }
12093
12094
12095 999831 void eWizzrobe::wizzrobe_attack()
12096 {
12097
10/12
✓ Branch 0 taken 963878 times.
✓ Branch 1 taken 35953 times.
✓ Branch 2 taken 963878 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 920153 times.
✓ Branch 5 taken 43725 times.
✓ Branch 6 taken 916770 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 915150 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 915150 times.
999831 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12098 84681 return;
12099
12100
3/8
✓ Branch 0 taken 876511 times.
✓ Branch 1 taken 38639 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 876511 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
915150 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12101 {
12102 38639 fix_coords();
12103
12104
5/5
✓ Branch 0 taken 5392 times.
✓ Branch 1 taken 1034 times.
✓ Branch 2 taken 15841 times.
✓ Branch 3 taken 12533 times.
✓ Branch 4 taken 3839 times.
38639 switch(misc)
12105 {
12106 case 1: //walking
12107
2/2
✓ Branch 0 taken 9966 times.
✓ Branch 1 taken 2567 times.
12533 if(!m_walkflag(x,y,spw_door, dir))
12108 2567 misc=0;
12109 else
12110 {
12111 9966 clk3=16;
12112
12113
2/2
✓ Branch 0 taken 8630 times.
✓ Branch 1 taken 1336 times.
9966 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12114 {
12115 1336 wizzrobe_newdir(0);
12116 1336 }
12117 }
12118
12119 12533 break;
12120
12121 case 2: //phasing
12122 {
12123 3839 int32_t jx=x;
12124 3839 int32_t jy=y;
12125 3839 int32_t jdir=-1;
12126
12127
5/5
✓ Branch 0 taken 1939 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 462 times.
✓ Branch 3 taken 476 times.
✓ Branch 4 taken 482 times.
3839 switch(zc_oldrand()&7)
12128 {
12129 case 0:
12130 480 jx-=32;
12131 480 jy-=32;
12132 480 jdir=15;
12133 480 break;
12134
12135 case 1:
12136 462 jx+=32;
12137 462 jy-=32;
12138 462 jdir=9;
12139 462 break;
12140
12141 case 2:
12142 476 jx+=32;
12143 476 jy+=32;
12144 476 jdir=11;
12145 476 break;
12146
12147 case 3:
12148 482 jx-=32;
12149 482 jy+=32;
12150 482 jdir=13;
12151 482 break;
12152 }
12153
12154
10/10
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 1939 times.
✓ Branch 2 taken 1697 times.
✓ Branch 3 taken 203 times.
✓ Branch 4 taken 1572 times.
✓ Branch 5 taken 125 times.
✓ Branch 6 taken 1364 times.
✓ Branch 7 taken 208 times.
✓ Branch 8 taken 1124 times.
✓ Branch 9 taken 240 times.
3839 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12155 {
12156 1124 misc=3;
12157 1124 clk3=32;
12158 1124 dir=jdir;
12159 1124 break;
12160 }
12161 2715 }
12162 [[fallthrough]];
12163 case 3:
12164 3749 dir&=3;
12165 3749 misc=0;
12166 [[fallthrough]];
12167 case 0:
12168 19590 wizzrobe_newdir(64);
12169 [[fallthrough]];
12170 default:
12171
2/2
✓ Branch 0 taken 21583 times.
✓ Branch 1 taken 3399 times.
24982 if(!canmove(dir,(zfix)1,spw_door,false))
12172 {
12173
2/2
✓ Branch 0 taken 3160 times.
✓ Branch 1 taken 239 times.
3399 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12174 {
12175 3160 misc=1;
12176 3160 clk3=16;
12177 3160 }
12178 else
12179 {
12180 239 wizzrobe_newdir(64);
12181 239 misc=0;
12182 239 clk3=32;
12183 }
12184 3399 }
12185 else
12186 {
12187 21583 clk3=32;
12188 }
12189
12190 24982 break;
12191 }
12192
12193
2/2
✓ Branch 0 taken 34231 times.
✓ Branch 1 taken 4408 times.
38639 if(misc<0)
12194 4408 ++misc;
12195 38639 }
12196
12197 915150 --clk3;
12198
12199
3/3
✓ Branch 0 taken 240027 times.
✓ Branch 1 taken 612130 times.
✓ Branch 2 taken 62993 times.
915150 switch(misc)
12200 {
12201 case 1:
12202 case 3:
12203 240027 step=1;
12204 240027 break;
12205
12206 case 2:
12207 62993 step=0;
12208 62993 break;
12209
12210 default:
12211 612130 step=0.5;
12212 612130 break;
12213
12214 }
12215
12216 915150 move(step);
12217
12218 // if(d->misc1 && misc<=0 && clk3==28)
12219
5/6
✓ Branch 0 taken 915150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612130 times.
✓ Branch 3 taken 303020 times.
✓ Branch 4 taken 590879 times.
✓ Branch 5 taken 21251 times.
915150 if(dmisc1 && misc<=0 && clk3==28)
12220 {
12221
2/2
✓ Branch 0 taken 16668 times.
✓ Branch 1 taken 4583 times.
21251 if(dmisc2 != 1)
12222 {
12223
2/2
✓ Branch 0 taken 14765 times.
✓ Branch 1 taken 1903 times.
16668 if(lined_up(8,false) == dir)
12224 {
12225 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12226 // sfx(WAV_WAND,pan(int32_t(x)));
12227 1903 wizzrobe_attack_for_real();
12228 1903 fclk=30;
12229 1903 }
12230 16668 }
12231 else
12232 {
12233
2/2
✓ Branch 0 taken 3606 times.
✓ Branch 1 taken 977 times.
4583 if((zc_oldrand()%500)>=400)
12234 {
12235 977 wizzrobe_attack_for_real();
12236 977 fclk=30;
12237 977 }
12238 }
12239 21251 }
12240
12241
4/4
✓ Branch 0 taken 510813 times.
✓ Branch 1 taken 404337 times.
✓ Branch 2 taken 3984 times.
✓ Branch 3 taken 506829 times.
915150 if(misc==0 && (zc_oldrand()&127)==0)
12242 3984 misc=2;
12243
12244
4/4
✓ Branch 0 taken 66977 times.
✓ Branch 1 taken 848173 times.
✓ Branch 2 taken 63593 times.
✓ Branch 3 taken 3384 times.
915150 if(misc==2 && clk3==4)
12245 3384 fix_coords();
12246
12247
2/4
✓ Branch 0 taken 915150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 915150 times.
915150 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12248 {
12249
2/2
✓ Branch 0 taken 833112 times.
✓ Branch 1 taken 82038 times.
915150 if(fclk>0)
12250 {
12251 82038 --fclk;
12252 82038 }
12253 915150 }
12254
12255 999831 }
12256
12257 21165 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12258 {
12259 // Wizzrobes shouldn't move to the edge of the screen;
12260 // if they're already there, they should move toward the center
12261
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21132 times.
21165 if(x<32)
12262 33 dir=right;
12263
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21128 times.
21132 else if(x>=world_w-32)
12264 4 dir=left;
12265
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21126 times.
21128 else if(y<32)
12266 2 dir=down;
12267
2/2
✓ Branch 0 taken 21121 times.
✓ Branch 1 taken 5 times.
21126 else if(y>=world_h-32)
12268 5 dir=up;
12269 else
12270 21121 newdir(4,homing,spw_wizzrobe);
12271 21165 }
12272
12273 2078953 void eWizzrobe::draw(BITMAP *dest)
12274 {
12275 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12276
13/14
✓ Branch 0 taken 1022531 times.
✓ Branch 1 taken 1056422 times.
✓ Branch 2 taken 806220 times.
✓ Branch 3 taken 216311 times.
✓ Branch 4 taken 127395 times.
✓ Branch 5 taken 895136 times.
✓ Branch 6 taken 126079 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 125253 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 120459 times.
✓ Branch 11 taken 4794 times.
✓ Branch 12 taken 120459 times.
✗ Branch 13 not taken.
2078953 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12277 120459 return;
12278
12279 1958494 int32_t tempint=dummy_int[1];
12280 1958494 bool tempbool1=dummy_bool[1];
12281 1958494 bool tempbool2=dummy_bool[2];
12282 1958494 dummy_int[1]=fclk;
12283 1958494 dummy_bool[1]=charging;
12284 1958494 dummy_bool[2]=firing;
12285 1958494 update_enemy_frame();
12286 1958494 dummy_int[1]=tempint;
12287 1958494 dummy_bool[1]=tempbool1;
12288 1958494 dummy_bool[2]=tempbool2;
12289 1958494 enemy::draw(dest);
12290 2078953 }
12291
12292 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12293 203 {
12294 203 fading=fade_flash_die;
12295
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12296 {
12297 3 dir=up;
12298 3 }
12299
12300
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12301 {
12302 dir=left;
12303 }
12304
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12305 203 }
12306
12307 125855 bool eDodongo::animate(int32_t index)
12308 {
12309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12310
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12311 {
12312 3790 return Dead(index);
12313 }
12314
12315
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12316 {
12317 569 removearmos(x,y,ffcactivated);
12318 569 }
12319
12320
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12321 {
12322
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12323 113 hp-=misc; // store bomb's power in misc
12324 10848 }
12325 else
12326 111217 constant_walk(rate,homing,spw_clipright);
12327
12328 122065 hit_width = (dir<=down) ? 16 : 32;
12329 // hysz = (dir>=left) ? 16 : 32;
12330
12331 122065 return enemy::animate(index);
12332 125855 }
12333
12334 125845 void eDodongo::draw(BITMAP *dest)
12335 {
12336 125845 tile=o_tile;
12337
12338
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12339 {
12340 3065 enemy::drawzcboss(dest);
12341 3065 return;
12342 }
12343
12344 122780 update_enemy_frame();
12345 122780 enemy::drawzcboss(dest);
12346
12347
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12348 {
12349 71118 tile+=dummy_int[1]; //second tile is previous tile
12350 71118 xofs-=16; //new xofs change
12351 71118 enemy::drawzcboss(dest);
12352 71118 xofs+=16;
12353 71118 }
12354
12355 125845 }
12356
12357 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12358 {
12359 8218 int32_t wpnId = w->id;
12360 8218 int32_t power = w->power;
12361 8218 int32_t wpnx = w->x;
12362 8218 int32_t wpny = w->y;
12363
12364
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12365 5761 return 0;
12366
12367
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12368 {
12369 case wPhantom:
12370 return 0;
12371
12372 case wFire:
12373 case wBait:
12374 case wWhistle:
12375 case wWind:
12376 case wSSparkle:
12377 case wFSparkle:
12378 return 0;
12379
12380 case wLitBomb:
12381 case wLitSBomb:
12382
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12383 690 return 0;
12384
12385 113 clk2=96;
12386 113 misc=power;
12387
12388
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12389 3 item_set=isSBOMB100;
12390
12391 113 return 1;
12392
12393 case wBomb:
12394 case wSBomb:
12395
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12396 516 return 0;
12397
12398 975 stunclk=160;
12399 975 misc=wpnId; // store wpnId
12400 975 return 1;
12401
12402 case wSword:
12403
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12404 {
12405 88 sfx(WAV_EHIT,pan(int32_t(x)));
12406 88 hp=0;
12407 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12408 88 fading=0; // don't flash
12409 88 return 1;
12410 }
12411
12412 [[fallthrough]];
12413 default:
12414 75 sfx(WAV_CHINK,pan(int32_t(x)));
12415 75 }
12416
12417 75 return 1;
12418 8218 }
12419
12420 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12421 48 {
12422 48 fading=fade_flash_die;
12423 //nets+5180;
12424 48 previous_dir=-1;
12425
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12426 {
12427 1 dir=up;
12428 1 }
12429
12430
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12431 {
12432 dir=left;
12433 }
12434
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12435 48 }
12436
12437 39398 bool eDodongo2::animate(int32_t index)
12438 {
12439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12440
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12441 {
12442 1158 return Dead(index);
12443 }
12444
12445
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12446 {
12447 167 removearmos(x,y,ffcactivated);
12448 167 }
12449
12450
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12451 {
12452
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12453 42 hp-=misc; // store bomb's power in misc
12454 4032 }
12455 else
12456 34208 constant_walk(rate,homing,spw_clipbottomright);
12457
12458 38240 hit_width = (dir<=down) ? 16 : 32;
12459 38240 hit_height = (dir>=left) ? 16 : 32;
12460 38240 hxofs=(dir>=left)?-8:0;
12461 38240 hyofs=(dir<left)?-8:0;
12462
12463 38240 return enemy::animate(index);
12464 39398 }
12465
12466 39601 void eDodongo2::draw(BITMAP *dest)
12467 {
12468
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12469 {
12470 768 enemy::drawzcboss(dest);
12471 768 return;
12472 }
12473
12474 38833 int32_t tempx=xofs;
12475 38833 int32_t tempy=yofs;
12476 38833 update_enemy_frame();
12477 38833 enemy::drawzcboss(dest);
12478 38833 tile+=dummy_int[1]; //second tile change
12479 38833 xofs+=dummy_int[2]; //new xofs change
12480 38833 yofs+=dummy_int[3]; //new yofs change
12481 38833 enemy::drawzcboss(dest);
12482 38833 xofs=tempx;
12483 38833 yofs=tempy;
12484 39601 }
12485
12486 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12487 {
12488 3929 int32_t wpnId = w->id;
12489 3929 int32_t power = w->power;
12490 3929 int32_t wpnx = w->x;
12491 3929 int32_t wpny = w->y;
12492
12493
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12494 2377 return 0;
12495
12496
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12497 {
12498 case wPhantom:
12499 return 0;
12500
12501 case wFire:
12502 case wBait:
12503 case wWhistle:
12504 case wWind:
12505 case wSSparkle:
12506 case wFSparkle:
12507 346 return 0;
12508
12509 case wLitBomb:
12510 case wLitSBomb:
12511
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12512 {
12513 case up:
12514
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12515 77 return 0;
12516
12517 4 break;
12518
12519 case down:
12520
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12521 71 return 0;
12522
12523 6 break;
12524
12525 case left:
12526
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12527 66 return 0;
12528
12529 16 break;
12530
12531 case right:
12532
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12533 65 return 0;
12534
12535 16 break;
12536 }
12537
12538 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12539 // return 0;
12540 42 clk2=96;
12541 42 misc=power;
12542
12543
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12544 item_set=isSBOMB100;
12545
12546 42 return 1;
12547
12548 case wBomb:
12549 case wSBomb:
12550
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12551 {
12552 case up:
12553
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12554 84 return 0;
12555
12556 92 break;
12557
12558 case down:
12559
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12560 113 return 0;
12561
12562 55 break;
12563
12564 case left:
12565
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12566 80 return 0;
12567
12568 105 break;
12569
12570 case right:
12571
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12572 71 return 0;
12573
12574 93 break;
12575 }
12576
12577 345 stunclk=160;
12578 345 misc=wpnId; // store wpnId
12579 345 return 1;
12580
12581 case wSword:
12582
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12583 {
12584 34 sfx(WAV_EHIT,pan(int32_t(x)));
12585 34 hp=0;
12586 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12587 34 fading=0; // don't flash
12588 34 return 1;
12589 }
12590
12591 [[fallthrough]];
12592 default:
12593 158 sfx(WAV_CHINK,pan(int32_t(x)));
12594 158 }
12595
12596 158 return 1;
12597 3929 }
12598
12599 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12600 126 {
12601 //these are here to bypass compiler warnings about unused arguments
12602
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12603 {
12604
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12605 126 }
12606 else { x = X; y = Y; }
12607
12608 //nets+5940;
12609
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12610 {
12611 81 }
12612 else
12613 {
12614
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12615 {
12616 7 flip=1;
12617 7 }
12618 }
12619
12620
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12621 126 clk3=32;
12622 126 clk2=0;
12623 126 clk4=clk;
12624 126 dir=left;
12625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12626 126 }
12627
12628 71899 bool eAquamentus::animate(int32_t index)
12629 {
12630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12631
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12632 2092 return Dead(index);
12633
12634 // fbx=x+((id==eRAQUAM)?4:-4);
12635
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12636 {
12637 317 removearmos(x,y,ffcactivated);
12638 317 }
12639
12640 69807 fbx=x;
12641
12642 /*
12643 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12644 {
12645 fbx+=16;
12646 }
12647 */
12648
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12649 {
12650 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12651 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12652 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12653 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12654 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12655 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12656 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12657 450 }
12658
12659
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12660 {
12661 345 clk3=32;
12662 345 }
12663
12664 69807 int screen_x = x.getInt()%256;
12665
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12666 {
12667 1117 int32_t d2=(zc_oldrand()%3)+1;
12668
12669
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12670 {
12671 752 dir=d2;
12672 752 }
12673
12674
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12675 {
12676
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12677 {
12678 38 dir=right;
12679 38 }
12680
12681
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12682 {
12683 dir=left;
12684 }
12685 385 }
12686 else
12687 {
12688
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12689 {
12690 21 dir=right;
12691 21 }
12692
12693
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12694 {
12695 34 dir=left;
12696 34 }
12697 }
12698 1117 }
12699
12700
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12701 {
12702
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12703 {
12704 4546 x-=1;
12705 4546 }
12706 else
12707 {
12708 3995 x+=1;
12709 }
12710 8541 }
12711
12712 69807 clk4=(clk4+1)%256;
12713
12714 69807 return enemy::animate(index);
12715 71899 }
12716
12717 72310 void eAquamentus::draw(BITMAP *dest)
12718 {
12719
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12720 {
12721 44994 xofs=(dmisc1?-16:0);
12722
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12723
12724
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12725 {
12726 1312 xofs=0;
12727 1312 enemy::draw(dest);
12728 1312 }
12729 else
12730 {
12731 43682 drawblock(dest,15);
12732 }
12733 44994 }
12734 else
12735 {
12736 27316 int32_t xblockofs=((dmisc1)?-16:16);
12737 27316 xofs=0;
12738
12739
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12740 {
12741 1462 enemy::draw(dest);
12742 1462 return;
12743 }
12744
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12745 {
12746 // face (0=firing, 2=resting)
12747 25854 tile=o_tile+((clk3>0)?0:2);
12748 25854 enemy::draw(dest);
12749 // tail (
12750 25854 tile=o_tile+((clk&16)?1:3);
12751 25854 xofs=xblockofs;
12752 25854 enemy::draw(dest);
12753 // body
12754 25854 yofs+=16;
12755 25854 xofs=0;
12756 25854 tile=o_tile+((clk&16)?20:22);
12757 25854 enemy::draw(dest);
12758 25854 xofs=xblockofs;
12759 25854 tile=o_tile+((clk&16)?21:23);
12760 25854 enemy::draw(dest);
12761 25854 yofs-=16;
12762 25854 }
12763 else enemy::draw(dest);
12764 }
12765 72310 }
12766
12767 23834 bool eAquamentus::hit(weapon *w)
12768 {
12769
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12770
12771
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12772 {
12773 case wBeam:
12774 case wRefBeam:
12775 case wMagic:
12776 4201 hit_height=32;
12777 4201 }
12778
12779
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12780 23834 hit_height=16;
12781 23834 return ret;
12782
12783 23834 }
12784
12785 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12786 93 {
12787
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12788 {
12789
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12790 93 }
12791 else { x = X; y = Y; }
12792
12793 93 Clk=Clk;
12794
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12795 {
12796 clk=0;
12797 superman = 1;
12798 fading=fade_flicker;
12799 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12800 }
12801
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12802 {
12803 42 clk=0;
12804 42 }
12805 93 hxofs=-16;
12806 93 hit_width=48;
12807 93 clk4=0;
12808
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12809
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12810
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12811
12812 //nets+5340;
12813 93 }
12814
12815 70891 bool eGohma::animate(int32_t index)
12816 {
12817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12818
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12819 1226 return Dead(index);
12820
12821
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12822 {
12823
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12824 {
12825 35 clk4=0;
12826 35 superman=0;
12827 35 fading=0;
12828 35 clk=0;
12829
12830 35 }
12831 1 else return enemy::animate(index);
12832 35 }
12833
12834
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12835 {
12836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(*ffcactivated);
12837 else
12838 {
12839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12840 350 did_armos = false;
12841 350 removearmos(x,y);
12842 350 did_armos = false;
12843
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12844 }
12845 350 }
12846
12847
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12848
12849 // Movement clk must be separate from animation clk because of the Clock item
12850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12851 68878 clk4++;
12852
12853
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12854 {
12855
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12856 546 dir^=1;
12857 else
12858 486 dir=zc_oldrand()%3+1;
12859 1032 }
12860
12861
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12862 {
12863
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12864 {
12865 case 1:
12866 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12867 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12868 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12869 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12870 235 break;
12871
12872 default:
12873
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12874 {
12875 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12876 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12877 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12878 754 }
12879
12880 882 break;
12881 }
12882 1117 }
12883
12884
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12885 {
12886
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12887 {
12888 290 FireBreath(true);
12889 290 }
12890 2215 }
12891
12892
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12893 34479 move((zfix)1);
12894
12895
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12896 150 clk3=0;
12897
12898 68878 return enemy::animate(index);
12899 70891 }
12900
12901 70889 void eGohma::draw(BITMAP *dest)
12902 {
12903 70889 tile=o_tile;
12904
12905
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12906 {
12907 2012 enemy::drawzcboss(dest);
12908 2012 return;
12909 }
12910
12911
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12912 {
12913 ///if ( do_animation )
12914 //Yuck. Gohma can just not have this capability right now.
12915 // left side
12916 53472 xofs=-16;
12917 53472 flip=0;
12918 // if(clk&16) tile=180;
12919 // else { tile=182; flip=1; }
12920 53472 tile+=(3*((clk&48)>>4));
12921 53472 enemy::drawzcboss(dest);
12922
12923 // right side
12924 53472 xofs=16;
12925 // tile=(180+182)-tile;
12926 53472 tile=o_tile;
12927 53472 tile+=(3*((clk&48)>>4))+2;
12928 53472 enemy::drawzcboss(dest);
12929
12930 // body
12931 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12932 53472 tile=o_tile;
12933
12934 // tile+=(3*((clk&24)>>3))+2;
12935
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12936 2975 tile+=7;
12937
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12938 15890 tile+=10;
12939
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12940 2051 tile+=7;
12941 else
12942 32556 tile+=((clk3-132)&24)?4:1;
12943
12944 53472 enemy::drawzcboss(dest);
12945
12946 53472 }
12947 else
12948 {
12949 // left side
12950 15405 xofs=-16;
12951 15405 flip=0;
12952
12953
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12954 {
12955 7790 tile+=2;
12956 7790 flip=1;
12957 7790 }
12958
12959 15405 enemy::draw(dest);
12960
12961 // right side
12962 15405 tile=o_tile;
12963 15405 xofs=16;
12964
12965
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12966
12967 // tile=(180+182)-tile;
12968 15405 enemy::draw(dest);
12969
12970 // body
12971 15405 tile=o_tile;
12972 15405 xofs=0;
12973
12974
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12975 912 tile+=4;
12976
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12977 4882 tile+=5;
12978
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12979 585 tile+=4;
12980 9026 else tile+=((clk3-132)&8)?3:1;
12981
12982 15405 enemy::draw(dest);
12983
12984 }
12985 70889 }
12986
12987 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12988 {
12989 578 int32_t wpnId = w->id;
12990 578 int32_t power = w->power;
12991 578 int32_t wpnx = w->x;
12992 578 int32_t wpnDir = w->dir;
12993 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12994
12995
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12996 {
12997
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12998 {
12999 93 sfx(WAV_CHINK,pan(int32_t(x)));
13000 93 return 1;
13001 }
13002 328 }
13003
13004 485 return enemy::takehit(w, realweap);
13005 578 }
13006
13007 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13008 327 {
13009 327 count_enemy=(id==(id&0xFFF));
13010 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13011
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13012 327 }
13013
13014 124050 bool eLilDig::animate(int32_t index)
13015 {
13016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13017
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13018 4410 return Dead(index);
13019
13020
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13021 {
13022 7105 removearmos(x,y,ffcactivated);
13023 7105 }
13024
13025
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13026 {
13027
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13028 1161 step+=0.25;
13029 38646 }
13030
13031 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13032 119640 return enemy::animate(index);
13033 124050 }
13034
13035 124268 void eLilDig::draw(BITMAP *dest)
13036 {
13037 124268 tile = o_tile;
13038 // tile = 160;
13039 124268 int32_t fdiv = frate/4;
13040
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13041
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13042 124268 efrate:((clk>=(frate>>1))?1:0);
13043
13044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13045 {
13046
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13047 {
13048
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13049 {
13050 case up: //u
13051 11370 flip=0;
13052 11370 break;
13053
13054 case l_up: //d
13055 10699 flip=0;
13056 10699 tile+=4;
13057 10699 break;
13058
13059 case l_down: //l
13060 10722 flip=0;
13061 10722 tile+=8;
13062 10722 break;
13063
13064 case left: //r
13065 12015 flip=0;
13066 12015 tile+=12;
13067 12015 break;
13068
13069 case r_down: //ul
13070 10070 flip=0;
13071 10070 tile+=20;
13072 10070 break;
13073
13074 case down: //ur
13075 9554 flip=0;
13076 9554 tile+=24;
13077 9554 break;
13078
13079 case r_up: //dl
13080 8255 flip=0;
13081 8255 tile+=28;
13082 8255 break;
13083
13084 case right: //dr
13085 10033 flip=0;
13086 10033 tile+=32;
13087 10033 break;
13088 }
13089
13090 91457 tile+=f2;
13091 91457 }
13092 else
13093 {
13094 32811 tile+=(clk>=6)?1:0;
13095 }
13096 124268 }
13097
13098 124268 enemy::draw(dest);
13099 124268 }
13100
13101 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13102 80 {
13103
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13104 80 }
13105
13106 29662 bool eBigDig::animate(int32_t index)
13107 {
13108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13110 return Dead(index);
13111
13112
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13113 {
13114 4104 removearmos(x,y,ffcactivated);
13115 4104 }
13116
13117
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13118 {
13119 case 0:
13120 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13121 29534 break;
13122
13123 case 1:
13124 64 ++misc;
13125 64 break;
13126
13127 case 2:
13128
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13129 {
13130 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13131 111 }
13132
13133
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13134 {
13135 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13136 30 }
13137
13138
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13139 {
13140 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13141 30 }
13142
13143
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13144 {
13145 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13146 30 }
13147
13148
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13149 {
13150 2 int guycarryingitem = guys.Count()-1;
13151 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13152 2 itemguy = false;
13153 2 }
13154
13155 64 stop_bgsfx(index);
13156
13157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13158
13159 64 return true;
13160 }
13161
13162 29598 return enemy::animate(index);
13163 29662 }
13164
13165 29658 void eBigDig::draw(BITMAP *dest)
13166 {
13167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13168 {
13169 update_enemy_frame();
13170 xofs-=8;
13171 yofs-=8;
13172 drawblock(dest,15);
13173 xofs+=8;
13174 yofs+=8;
13175 return;
13176 }
13177
13178 29658 tile = o_tile;
13179 29658 int32_t fdiv = frate/4;
13180
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13181
13182
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13183 29658 efrate:((clk>=(frate>>1))?1:0);
13184
13185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13186 {
13187
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13188 {
13189
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13190 {
13191 case up: //u
13192 1688 flip=0;
13193 1688 break;
13194
13195 case l_up: //d
13196 1684 flip=0;
13197 1684 tile+=8;
13198 1684 break;
13199
13200 case l_down: //l
13201 2031 flip=0;
13202 2031 tile+=40;
13203 2031 break;
13204
13205 case left: //r
13206 1910 flip=0;
13207 1910 tile+=48;
13208 1910 break;
13209
13210 case r_down: //ul
13211 2041 flip=0;
13212 2041 tile+=80;
13213 2041 break;
13214
13215 case down: //ur
13216 2043 flip=0;
13217 2043 tile+=88;
13218
13219 2043 break;
13220
13221 case r_up: //dl
13222 1514 flip=0;
13223 1514 tile+=120;
13224 1514 break;
13225
13226 case right: //dr
13227 2241 flip=0;
13228 2241 tile+=128;
13229 2241 break;
13230 }
13231
13232 16161 tile+=(f2*2);
13233 16161 }
13234 else
13235 {
13236 13497 tile+=(f2)?0:2;
13237 13497 flip=(clk&1)?1:0;
13238 }
13239 29658 }
13240
13241 29658 xofs-=8;
13242 29658 yofs-=8;
13243 29658 drawblock(dest,15);
13244 29658 xofs+=8;
13245 29658 yofs+=8;
13246 29658 }
13247
13248 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13249 {
13250 869 int32_t wpnId = w->id;
13251
13252
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13253 {
13254 64 misc = 1;
13255 64 w->hit_pierce(this, 0, false);
13256 64 }
13257
13258 869 return 0;
13259 }
13260
13261 80 void eBigDig::init_size_flags()
13262 {
13263 80 SIZEflags = d->SIZEflags;
13264
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13265 // al_trace("Enemy txsz:%i\n", txsz);
13266
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13268 80 else hit_width = 32;
13269
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13270 80 else hit_height = 32;
13271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13272 80 else hzsz = 16; // hard to jump.
13273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13274 80 else hxofs = -8;
13275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13276 80 else hyofs = -8;
13277 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13278
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13279
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13280 {
13281 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13282 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13283 }
13284
13285
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13286 80 }
13287
13288 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13289 13 {
13290 13 hxofs=hyofs=8;
13291
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13292 {
13293 hxofs = 4;
13294 hyofs = 4;
13295 hit_width = 24;
13296 hit_height = 24;
13297 SIZEflags|=OVERRIDE_HIT_WIDTH;
13298 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13299 }
13300 13 hzsz=16; //can't be jumped.
13301 13 clk2=70;
13302 13 misc=-1;
13303
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13304
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13305 13 }
13306
13307 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13308 {
13309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13310
13311 return Dead(index);
13312
13313
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13314 {
13315 72 removearmos(x,y,ffcactivated);
13316 72 }
13317
13318
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13319 {
13320 case -1:
13321 13 misc=0;
13322 [[fallthrough]];
13323 case 0:
13324
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13325 {
13326 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13327 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13328 173 clk2=0;
13329 173 }
13330
13331 12693 Stunclk=0;
13332 12693 constant_walk(rate,homing,spw_none);
13333 12693 break;
13334
13335 case 1:
13336 case 2:
13337
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13338 {
13339 41 int32_t r=zc_oldrand();
13340
13341
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13342 {
13343 17 y=96;
13344
13345
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13346 6 x=160;
13347 else
13348 11 x=48;
13349
13350
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13351 8 x=208-x;
13352
13353 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13354 17 }
13355
13356 41 loadpalset(csBOSS,pSprite(d->bosspal));
13357 41 misc=0;
13358 41 }
13359
13360 3607 break;
13361
13362 case 3:
13363 {
13364
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13365 972 break;
13366
13367 12 misc=4;
13368 12 clk=0;
13369 12 hxofs=1000;
13370 12 loadpalset(9,pSprite(spPILE));
13371 12 music_stop();
13372 12 stop_sfx(WAV_ROAR);
13373
13374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13375
13376 12 sfx(WAV_GANON);
13377 //Ganon's dustpile; fall in sideview. -Z
13378 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13379 //dustpile->miscellaneous[31] = eeGANON;
13380
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13381 12 item *dustpile = NULL;
13382 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13383 12 dustpile = (item *)items.spr(items.Count() - 1);
13384 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13385 12 break;
13386 }
13387
13388 case 4:
13389
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13390 {
13391 12 misc=5;
13392
13393 //game->lvlitems[dlevel]|=liBOSS;
13394
13395 12 sfx(WAV_CLEARED);
13396 //Add the big TF over the ashes!
13397
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13398 {
13399 24 item *ashes = (item*)items.spr(q);
13400
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13401 {
13402 //Z_scripterrlog("Found correct dustpile!\n");
13403
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13404 12 item *bigtriforce = NULL;
13405 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13406 12 bigtriforce->linked_parent = eeGANON;
13407 12 }
13408 24 }
13409 12 }
13410
13411 960 break;
13412 10 case 5: return true;
13413 }
13414
13415 18244 return enemy::animate(index);
13416 18254 }
13417
13418
13419 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13420 {
13421 //these are here to bypass compiler warnings about unused arguments
13422 964 int32_t wpnId = w->id;
13423 964 int32_t power = w->power;
13424 964 int32_t enemyHitWeapon = w->parentitem;
13425
13426
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13427 {
13428 case 0:
13429
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13430 31 return 0;
13431
13432 53 hp-=power;
13433
13434
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13435 {
13436 41 misc=1;
13437 41 Stunclk=64;
13438 41 }
13439 else
13440 {
13441 12 loadpalset(csBOSS,pSprite(spBROWN));
13442 12 misc=2;
13443 12 Stunclk=284;
13444 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13445 }
13446
13447 53 sfx(WAV_EHIT,pan(int32_t(x)));
13448
13449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13450
13451 53 return 1;
13452
13453 case 2:
13454
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13455 154 return 0;
13456
13457 12 misc=3;
13458 12 hclk=81;
13459 12 loadpalset(9,pSprite(spBROWN));
13460 12 return 1;
13461 }
13462
13463 714 return 0;
13464 964 }
13465
13466 20776 void eGanon::draw(BITMAP *dest)
13467 {
13468
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13469 {
13470 case 0:
13471
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13472 3169 tile=(zc_oldrand()%5)*2+o_tile;
13473
13474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13475 {
13476
13477 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13478 {
13479 int odraw = drawstyle;
13480 drawstyle = 2;
13481 drawblock(dest,15);
13482 drawstyle = odraw;
13483 }
13484 else
13485 {
13486 drawblock(dest,15);
13487 }
13488 break;
13489
13490 }
13491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13492 {
13493 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13494 {
13495 int odraw = drawstyle;
13496 drawstyle = 2;
13497 drawblock(dest,15);
13498 drawstyle = odraw;
13499 }
13500 else
13501 {
13502 drawblock(dest,15);
13503 }
13504 break;
13505 }
13506
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13507 12680 break;
13508 [[fallthrough]];
13509 case 2:
13510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13511 break;
13512 [[fallthrough]];
13513 case -1:
13514 3518 tile=o_tile;
13515
13516 [[fallthrough]];
13517 case 1:
13518 case 3:
13519 7126 drawblock(dest,15);
13520 7126 break;
13521
13522 case 4:
13523 960 draw_guts(dest);
13524 960 draw_flash(dest);
13525 960 break;
13526 }
13527 20776 }
13528
13529 960 void eGanon::draw_guts(BITMAP *dest)
13530 {
13531
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13532 960 tile = clk<24 ? 74 : 75;
13533 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13534 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13535 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13536 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13537 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13538 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13539 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13540 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13541 960 }
13542
13543 960 void eGanon::draw_flash(BITMAP *dest)
13544 {
13545
13546 960 int32_t c = clk-(clk>>2);
13547 960 cs = (frame&3)+6;
13548 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13549 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13550 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13551 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13552 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13553 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13554 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13555 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13556 960 }
13557
13558 15 void getBigTri(mapscr* scr, int32_t id2)
13559 {
13560 /*
13561 *************************
13562 * BIG TRIFORCE SEQUENCE *
13563 *************************
13564 0 BIGTRI out, WHITE flash in
13565 4 WHITE flash out, PILE cset white
13566 8 WHITE in
13567 ...
13568 188 WHITE out
13569 191 PILE cset red
13570 200 top SHUTTER opens
13571 209 bottom SHUTTER opens
13572 */
13573 15 sfx(itemsbuf[id2].playsound);
13574 15 guys.clear();
13575
13576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13577 {
13578 game->lvlitems[dlevel]|=liTRIFORCE;
13579 }
13580
13581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13582
13583 15 draw_screen();
13584
13585
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13586 {
13587
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13588 {
13589
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13590 {
13591 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13592 225 }
13593 15 }
13594
13595
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13596 {
13597
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13598 {
13599
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13600 {
13601 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13602 16200 }
13603 1080 }
13604
13605 360 refreshpal=true;
13606 360 }
13607
13608
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13609 {
13610
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13611 else loadlvlpal(0xB);
13612 360 }
13613
13614
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13615 {
13616 15 loadpalset(9,pSprite(spPILE));
13617 15 }
13618
13619 2880 advanceframe(true);
13620 2880 }
13621
13622 //play_DmapMusic();
13623 15 playLevelMusic();
13624
13625
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13626 {
13627 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13628 2 }
13629 15 }
13630
13631 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13632 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13633 618 {
13634
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13635 {
13636
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13637 618 }
13638 //else { x = X; y = Y; }
13639
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13640 618 superman=1;
13641 618 fading=fade_invisible;
13642 618 hxofs=1000;
13643 618 segcnt=clk;
13644 618 segid=Id|0x1000;
13645 618 clk=0;
13646
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13647
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13648 618 tile=o_tile;
13649 618 hitdir = -1;
13650 618 stickclk = 0;
13651
13652 /*
13653 if (get_qr(qr_NEWENEMYTILES))
13654 {
13655 tile=nets+1220;
13656 }
13657 else
13658 {
13659 tile=57;
13660 }
13661 */
13662 618 }
13663
13664 244844 bool eMoldorm::animate(int32_t index)
13665 {
13666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13667 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13668
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13669 {
13670 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13671 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13672 28475 }
13673
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13674 {
13675 562 stickclk = 0;
13676 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13677 562 }
13678
13679
13680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13681 {
13682 244844 removearmos(x,y,ffcactivated);
13683 244844 }
13684
13685
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13686 {
13687
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13688 {
13689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13690 129 never_return(screen_spawned, index);
13691
13692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13693 129 leave_item();
13694
13695 129 stop_bgsfx(index);
13696 129 return true;
13697 }
13698 2322 }
13699 else
13700 {
13701
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13702 stunclk=0;
13703 242393 constant_walk_8_old(rate,homing,spw_floater);
13704
13705
13706 242393 misc=dir;
13707
13708 // If any higher-numbered segments were killed, segcnt can be too high,
13709 // leading to a crash
13710
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13711 segcnt=guys.Count()-index-1;
13712
13713
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13714 {
13715 1122281 enemy* segment=((enemy*)guys.spr(i));
13716
13717 // More validation - if segcnt was wrong, this may not
13718 // actually be a Moldorm segment
13719
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13720 {
13721 segcnt=i-index-1;
13722 break;
13723 }
13724
13725
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13726 {
13727 242669 x=segment->x;
13728 242669 y=segment->y;
13729 242669 }
13730
13731 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13732 //Script your own blasted segmented bosses!! -Z
13733 1122281 segment->setParent(this);
13734
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13735 {
13736 217733 segment->dummy_int[1]=2;
13737 217733 }
13738 else
13739 {
13740 904548 segment->dummy_int[1]=1;
13741 }
13742
13743
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13744 {
13745 242669 segment->dummy_int[1]=0;
13746 242669 }
13747
13748
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13749 {
13750 1016 int32_t offset=1;
13751
13752
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13753 {
13754 // Triple-check
13755
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13756 {
13757 segcnt=j-index+1; // Add 1 because of --segcnt below
13758 break;
13759 }
13760 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13761 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13762 1480 }
13763
13764 1016 segment->hclk=33;
13765 1016 --segcnt;
13766 1016 --i; // Recheck the same index in case multiple segments died at once
13767 1016 }
13768 1122281 }
13769
13770
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13771 {
13772 129 clk2=19;
13773
13774 129 x=guys.spr(index+1)->x;
13775 129 y=guys.spr(index+1)->y;
13776 129 }
13777 }
13778
13779 244715 return false;
13780 244844 }
13781
13782 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13783 3150 {
13784
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13785 {
13786
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13787 3150 }
13788
13789
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13790 3150 hyofs=4;
13791 3150 hit_width=hit_height=8;
13792 3150 hxofs=1000;
13793 3150 mainguy=count_enemy=false;
13794 3150 parentclk = 0;
13795 3150 bgsfx=-1;
13796
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13797 //deadsfx = WAV_EDEAD;
13798 3150 isCore = false;
13799 3150 }
13800
13801 1138024 bool esMoldorm::animate(int32_t index)
13802 {
13803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13804 // Shouldn't be possible, but better to be sure
13805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13806 dying=true;
13807
13808
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13809 {
13810
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13811 15743 item_set=0;
13812
13813 15743 return Dead(index);
13814 }
13815
13816
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13817 {
13818 1017204 hxofs=4;
13819 1017204 step=((enemy*)guys.spr(index-1))->step;
13820
13821
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13822 {
13823 70455 misc=dir;
13824 70455 dir=((enemy*)guys.spr(index-1))->misc;
13825 //do alignment, as in parent's animation :-/ -DD
13826 70455 x.doFloor();
13827 70455 y.doFloor();
13828 70455 }
13829
13830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13831 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13832
13833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13834 {
13835 1017204 sprite::move(step);
13836 1017204 }
13837 1017204 }
13838
13839 1122281 return enemy::animate(index);
13840 1138024 }
13841
13842 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13843 {
13844
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13845 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13846
13847 453 return 0;
13848 2683 }
13849
13850 1155313 void esMoldorm::draw(BITMAP *dest)
13851 {
13852 1155313 tile=o_tile;
13853 1155313 int32_t fdiv = frate/4;
13854
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13855
13856
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13857 1155313 efrate:((clk>=(frate>>1))?1:0);
13858
13859
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13860 {
13861 1043930 tile+=dummy_int[1]*40;
13862
13863
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13864 {
13865 102730 flip=0;
13866
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13867
13868
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13869 tile+=4;
13870 102730 }
13871 else
13872 {
13873
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13874 {
13875 case up: //u
13876 96530 flip=0;
13877 96530 break;
13878
13879 case l_up: //d
13880 134534 flip=0;
13881 134534 tile+=4;
13882 134534 break;
13883
13884 case l_down: //l
13885 113426 flip=0;
13886 113426 tile+=8;
13887 113426 break;
13888
13889 case left: //r
13890 124800 flip=0;
13891 124800 tile+=12;
13892 124800 break;
13893
13894 case r_down: //ul
13895 101314 flip=0;
13896 101314 tile+=20;
13897 101314 break;
13898
13899 case down: //ur
13900 99043 flip=0;
13901 99043 tile+=24;
13902 99043 break;
13903
13904 case r_up: //dl
13905 131794 flip=0;
13906 131794 tile+=28;
13907 131794 break;
13908
13909 case right: //dr
13910 139759 flip=0;
13911 139759 tile+=32;
13912 139759 break;
13913 }
13914 }
13915
13916 1043930 tile+=f2;
13917 1043930 }
13918
13919
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13920 1049046 enemy::draw(dest);
13921 1155313 }
13922
13923 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13924 420 {
13925
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13926 {
13927
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13928 420 }
13929 //else { x = X; y = Y; }
13930 //byte legaldirs = 0;
13931 420 int32_t incr = 16;
13932 //int32_t possiiblepos = 0;
13933 //int32_t positions[8] = {0};
13934
13935 //Don't spawn in pits.
13936
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13937 {
13938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13939 {
13940 //move if we spawn over a pit
13941 //check each direction
13942
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13943 {
13944
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13945 }
13946
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13947 {
13948
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13949 }
13950
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13951 {
13952
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13953 }
13954
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13955 {
13956
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13957 }
13958
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13959 {
13960 y -= incr; break;
13961 }
13962
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13963 {
13964 y+=incr; break;
13965 }
13966
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13967 {
13968
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13969 }
13970
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13971 {
13972 x+=incr; y+=incr; break;
13973 }
13974 34 else continue;
13975
13976 }
13977
13978 105 }
13979
13980 420 dir=up;
13981 420 superman=1;
13982 420 fading=fade_invisible;
13983 420 hxofs=1000;
13984 420 segcnt=clk;
13985 420 clk=0;
13986 //set up move history
13987
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13988
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13989 420 }
13990
13991 236907 bool eLanmola::animate(int32_t index)
13992 {
13993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13994
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13995 {
13996 40196 removearmos(x,y,ffcactivated);
13997 40196 }
13998
13999
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14000 {
14001
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14002 {
14003
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14004 86 leave_item();
14005
14006 189 stop_bgsfx(index);
14007 189 return true;
14008 }
14009
14010 3402 return false;
14011 }
14012
14013
14014 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14015 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14016 //I've added a complete movement history to this enemy to compensate -DD
14017 233316 constant_walk(rate,homing,spw_none);
14018 233316 prevState.pop_front();
14019 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14020
14021 // This could cause a crash with Moldorms. I didn't see the same problem
14022 // with Lanmolas, but it looks like it ought to be possible, so here's
14023 // the same solution. - Saf
14024
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14025 segcnt=guys.Count()-index-1;
14026
14027
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14028 {
14029 966396 enemy* segment=((enemy*)guys.spr(i));
14030
14031 // More validation in case segcnt is wrong
14032
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14033 {
14034 segcnt=i-index-1;
14035 break;
14036 }
14037
14038 966396 segment->o_tile=o_tile;
14039 966396 segment->setParent(this);
14040
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14041 {
14042 195700 segment->dummy_int[1]=1; //tail
14043 195700 }
14044 else
14045 {
14046 770696 segment->dummy_int[1]=0;
14047 }
14048
14049
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14050 {
14051
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14052 {
14053 // Triple-check
14054
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14055 {
14056 segcnt=j-index+1; // Add 1 because of --segcnt below
14057 break;
14058 }
14059 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14060 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14061 1961 }
14062
14063 1169 ((enemy*)guys.spr(i))->hclk=33;
14064 1169 --segcnt;
14065 1169 --i; // Recheck the same index in case multiple segments died at once
14066 1169 }
14067 966396 }
14068
14069
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14070 {
14071 189 clk2=19;
14072 189 x=guys.spr(index+1)->x;
14073 189 y=guys.spr(index+1)->y;
14074 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14075 189 }
14076
14077 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14078 //which is... disastrous.
14079 233316 hp = 1;
14080 233316 return enemy::animate(index);
14081 236907 }
14082
14083 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14084 2267 {
14085
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14086 {
14087
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14088 2267 }
14089 2267 int32_t incr = 16;
14090 //Don't spawn in pits.
14091
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14092 {
14093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14094 {
14095 //move if we spawn over a pit
14096 //check each direction
14097
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14098 {
14099
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14100 }
14101
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14102 {
14103
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14104 }
14105
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14106 {
14107
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14108 }
14109
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14110 {
14111
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14112 }
14113
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14114 {
14115 y -= incr; break;
14116 }
14117
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14118 {
14119 y+=incr; break;
14120 }
14121
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14122 {
14123
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14124 }
14125
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14126 {
14127 x+=incr; y+=incr; break;
14128 }
14129 170 else continue;
14130
14131 }
14132
14133 525 }
14134
14135 2267 hxofs=1000;
14136 2267 hit_width=8;
14137 2267 mainguy=false;
14138 2267 count_enemy=(id<0x2000)?true:false;
14139
14140 //set up move history
14141
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14142
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14143
14144 2267 bgsfx = -1;
14145 2267 isCore = false;
14146
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14147 2267 }
14148
14149 985563 bool esLanmola::animate(int32_t index)
14150 {
14151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14152 // Shouldn't be possible, but who knows
14153
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14154 18 dying=true;
14155
14156
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14157 {
14158 19167 xofs=0;
14159
14160
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14161 9306 item_set=0;
14162
14163 19167 return Dead(index);
14164 }
14165
14166
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14167 {
14168 930450 hxofs=4;
14169
14170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14171 {
14172 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14173 930450 prevState.pop_front();
14174 930450 prevState.push_back(newstate);
14175 930450 x = newstate.first.first;
14176 930450 y = newstate.first.second;
14177 930450 dir = newstate.second;
14178 930450 }
14179 930450 }
14180
14181 966396 return enemy::animate(index);
14182 985563 }
14183
14184 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14185 {
14186
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14187 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14188
14189 590 return 0;
14190 2655 }
14191
14192 990931 void esLanmola::draw(BITMAP *dest)
14193 {
14194 990931 tile=o_tile;
14195 990931 int32_t fdiv = frate/4;
14196
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14197
14198
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14199 990931 efrate:((clk>=(frate>>1))?1:0);
14200
14201
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14202 {
14203
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14204 {
14205 481767 tile+=20;
14206
14207
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14208 {
14209 128742 tile+=20;
14210 128742 }
14211 481767 }
14212
14213
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14214 {
14215 case up:
14216 141419 flip=0;
14217 141419 break;
14218
14219 case down:
14220 140994 flip=0;
14221 140994 tile+=4;
14222 140994 break;
14223
14224 case left:
14225 159500 flip=0;
14226 159500 tile+=8;
14227 159500 break;
14228
14229 case right:
14230 187019 flip=0;
14231 187019 tile+=12;
14232 187019 break;
14233 }
14234
14235 628932 tile+=f2;
14236 628932 }
14237 else
14238 {
14239
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14240 {
14241 271456 tile+=1;
14242 271456 }
14243 }
14244
14245
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14246 953893 enemy::draw(dest);
14247 990931 }
14248
14249 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14250 150 {
14251 //these are here to bypass compiler warnings about unused arguments
14252 150 Clk=Clk;
14253 150 superman=1;
14254
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14255 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14256
14257
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14258 692 arm[i]=i;
14259
14260 150 fading=fade_blue_poof;
14261 //nets+4680;
14262 150 adjusted=false;
14263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14264 150 }
14265
14266 66494 bool eManhandla::animate(int32_t index)
14267 {
14268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14269
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14270 1382 return Dead(index);
14271
14272
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14273 {
14274 2471 removearmos(x,y,ffcactivated);
14275 2471 }
14276
14277
14278 // check arm status, move dead ones to end of group
14279
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14280 {
14281 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14282
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14283 {
14284
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14285 {
14286 552 zc_swap(arm[j],arm[j+1]);
14287 552 guys.swap(index+j+1,index+j+2);
14288 552 }
14289
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14290 {
14291 87 leave_item();
14292 87 }
14293 424 --armcnt;
14294 424 --i;
14295 424 continue;
14296 }
14297
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14298 {
14299
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14300 {
14301 508 cur_arm->o_tile=o_tile+40;
14302 508 cur_arm->setParent(this);
14303 508 }
14304 else
14305 {
14306 184 cur_arm->o_tile=o_tile+160;
14307 184 cur_arm->setParent(this);
14308 }
14309 692 }
14310 193194 }
14311
14312 65112 adjusted=true;
14313
14314 // move or die
14315
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14316 83 hp=0;
14317 else
14318 {
14319 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14320
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14321
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14322 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14323
14324
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14325 {
14326
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14327 {
14328
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14329 {
14330 case 0:
14331 38579 dy1=-24;
14332 38579 break;
14333
14334 case 1:
14335 36328 dy2=31;
14336 36328 break;
14337
14338 case 2:
14339 36250 dx1=-16;
14340 36250 break;
14341
14342 case 3:
14343 39862 dx2=31;
14344 39862 break;
14345 }
14346 151019 }
14347 53584 }
14348 else
14349 {
14350 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14351
14352
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14353 {
14354
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14355 {
14356 case 0:
14357 12012 dy1=-32;
14358 12012 break;
14359
14360 case 1:
14361 7730 dy2=39;
14362 7730 break;
14363
14364 case 2:
14365 9837 dx1=-24;
14366 9837 break;
14367
14368 case 3:
14369 12596 dx2=39;
14370 12596 break;
14371 }
14372 42175 }
14373 }
14374
14375 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14376
14377
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14378 {
14379 193194 zfix dx=(zfix)0,dy=(zfix)0;
14380
14381
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14382 {
14383
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14384 {
14385 case 0:
14386 38579 dy=-16;
14387 38579 break;
14388
14389 case 1:
14390 36328 dy=16;
14391 36328 break;
14392
14393 case 2:
14394 36250 dx=-16;
14395 36250 break;
14396
14397 case 3:
14398 39862 dx=16;
14399 39862 break;
14400 }
14401 151019 }
14402 else
14403 {
14404
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14405 {
14406 case 0:
14407 5447 dy=-24;
14408 5447 dx=-8;
14409 5447 break;
14410
14411 case 1:
14412 3986 dy=24;
14413 3986 dx=8;
14414 3986 break;
14415
14416 case 2:
14417 4163 dx=-24;
14418 4163 dy=8;
14419 4163 break;
14420
14421 case 3:
14422 6774 dx=24;
14423 6774 dy=-8;
14424 6774 break;
14425
14426 case 4:
14427 6565 dy=-24;
14428 6565 dx=8;
14429 6565 break;
14430
14431 case 5:
14432 3744 dy=24;
14433 3744 dx=-8;
14434 3744 break;
14435
14436 case 6:
14437 5674 dx=-24;
14438 5674 dy=-8;
14439 5674 break;
14440
14441 case 7:
14442 5822 dx=24;
14443 5822 dy=8;
14444 5822 break;
14445 }
14446 }
14447
14448 193194 guys.spr(index+i+1)->x = x+dx;
14449 193194 guys.spr(index+i+1)->y = y+dy;
14450 193194 }
14451 }
14452
14453 65112 return enemy::animate(index);
14454 66494 }
14455
14456
14457 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14458 {
14459 1751 int32_t wpnId = w->id;
14460
14461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14462 return 0;
14463
14464
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14465 {
14466 case wBomb:
14467 case wSBomb:
14468 case wSword:
14469 case wHammer:
14470 case wWand:
14471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14472
14473 case wLitBomb:
14474 case wLitSBomb:
14475 case wBait:
14476 case wWhistle:
14477 case wFire:
14478 case wWind:
14479 case wSSparkle:
14480 case wFSparkle:
14481 case wPhantom:
14482 1709 return 0;
14483
14484 case wHookshot:
14485 case wBrang:
14486 sfx(WAV_CHINK,pan(int32_t(x)));
14487 break;
14488
14489 default:
14490
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14491 else sfx(WAV_CHINK,pan(int32_t(x)));
14492
14493 42 }
14494
14495 42 return 1;
14496 1751 }
14497
14498 66490 void eManhandla::draw(BITMAP *dest)
14499 {
14500 66490 tile=o_tile;
14501 66490 int32_t fdiv = frate/4;
14502
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14503
14504
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14505 66490 efrate:((clk>=(frate>>1))?1:0);
14506
14507
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14508 {
14509
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14510 {
14511
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14512 {
14513 case up: //u
14514 4771 flip=0;
14515 4771 break;
14516
14517 case l_up: //d
14518 4640 flip=0;
14519 4640 tile+=4;
14520 4640 break;
14521
14522 case l_down: //l
14523 4995 flip=0;
14524 4995 tile+=8;
14525 4995 break;
14526
14527 case left: //r
14528 5574 flip=0;
14529 5574 tile+=12;
14530 5574 break;
14531
14532 case r_down: //ul
14533 3793 flip=0;
14534 3793 tile+=20;
14535 3793 break;
14536
14537 case down: //ur
14538 3930 flip=0;
14539 3930 tile+=24;
14540 3930 break;
14541
14542 case r_up: //dl
14543 3908 flip=0;
14544 3908 tile+=28;
14545 3908 break;
14546
14547 case right: //dr
14548 5883 flip=0;
14549 5883 tile+=32;
14550 5883 break;
14551 }
14552
14553 37494 tile+=f2;
14554 37494 enemy::draw(dest);
14555 37494 } //manhandla 2, big body
14556 else
14557 {
14558
14559
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14560 {
14561 case up: //u
14562 1277 flip=0;
14563 1277 break;
14564
14565 case l_up: //d
14566 1360 flip=0;
14567 1360 tile+=8;
14568 1360 break;
14569
14570 case l_down: //l
14571 2242 flip=0;
14572 2242 tile+=40;
14573 2242 break;
14574
14575 case left: //r
14576 1789 flip=0;
14577 1789 tile+=48;
14578 1789 break;
14579
14580 case r_down: //ul
14581 1345 flip=0;
14582 1345 tile+=80;
14583 1345 break;
14584
14585 case down: //ur
14586 805 flip=0;
14587 805 tile+=88;
14588 805 break;
14589
14590 case r_up: //dl
14591 948 flip=0;
14592 948 tile+=120;
14593 948 break;
14594
14595 case right: //dr
14596 1542 flip=0;
14597 1542 tile+=128;
14598 1542 break;
14599 }
14600
14601 11308 tile+=(f2*2);
14602 11308 xofs-=8;
14603 11308 yofs-=8;
14604 11308 drawblock(dest,15);
14605 11308 xofs+=8;
14606 11308 yofs+=8;
14607 }
14608 48802 }
14609 else
14610 {
14611
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14612 {
14613 17173 enemy::draw(dest);
14614 17173 }
14615 else
14616 {
14617 515 xofs-=8;
14618 515 yofs-=8;
14619 515 enemy::draw(dest);
14620 515 xofs+=16;
14621 515 enemy::draw(dest);
14622 515 yofs+=16;
14623 515 enemy::draw(dest);
14624 515 xofs-=16;
14625 515 enemy::draw(dest);
14626 515 xofs+=8;
14627 515 yofs-=8;
14628 }
14629 }
14630 66490 }
14631
14632 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14633 692 {
14634 692 id=misc=clk;
14635 692 dir = clk & 3;
14636 692 clk=0;
14637 692 mainguy=count_enemy=false;
14638 692 dummy_bool[0]=false;
14639 692 item_set=0;
14640 692 bgsfx=-1;
14641 692 deadsfx = WAV_EDEAD;
14642
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14643 692 isCore = false;
14644
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14645 692 }
14646
14647 200202 bool esManhandla::animate(int32_t index)
14648 {
14649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14650
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14651 7008 return Dead(index);
14652
14653
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14654 {
14655 12404 removearmos(x,y,ffcactivated);
14656 12404 }
14657
14658
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14659 {
14660 27896 clk2=unsigned(zc_oldrand())%5+5;
14661 27896 clk3^=1;
14662 27896 }
14663
14664
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14665 {
14666 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14667 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
14668 1491 }
14669
14670 193194 return enemy::animate(index);
14671 200202 }
14672
14673 200186 void esManhandla::draw(BITMAP *dest)
14674 {
14675 200186 tile=o_tile;
14676 200186 int32_t fdiv = frate/4;
14677
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14678
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14679 200186 efrate:((clk>=(frate>>1))?1:0);
14680
14681
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14682 {
14683
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14684 {
14685 case up:
14686 39945 break;
14687
14688 case down:
14689 36845 tile+=4;
14690 36845 break;
14691
14692 case left:
14693 39966 tile+=8;
14694 39966 break;
14695
14696 case right:
14697 41960 tile+=12;
14698 41960 break;
14699 }
14700
14701 158716 tile+=f2;
14702 158716 }
14703 else
14704 {
14705
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14706 {
14707 case down:
14708 8961 flip=2;
14709
14710 [[fallthrough]];
14711 case up:
14712 21355 tile=(clk3)?188:189;
14713 21355 break;
14714
14715 case right:
14716 12232 flip=1;
14717 [[fallthrough]];
14718
14719 case left:
14720 20115 tile=(clk3)?186:187;
14721 20115 break;
14722 }
14723 }
14724
14725 200186 enemy::draw(dest);
14726 200186 }
14727
14728 167 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14729 167 {
14730
1/2
✓ Branch 0 taken 167 times.
✗ Branch 1 not taken.
167 if ( !(editorflags & ENEMY_FLAG5) )
14731 {
14732
2/4
✓ Branch 0 taken 167 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 167 times.
✗ Branch 3 not taken.
167 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14733 167 }
14734 else
14735 {
14736 if ( !(editorflags & ENEMY_FLAG6) )
14737 {
14738 x = X; y = Y;
14739 }
14740 else
14741 {
14742 x = X+8; y = Y;
14743 }
14744 }
14745 167 hzsz = 32; // can't be jumped.
14746 167 flameclk=0;
14747 167 misc=clk; // total head count
14748 167 clk3=clk; // live head count
14749 167 clk=0;
14750 167 clk2=60; // fire ball clock
14751 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14752
1/2
✓ Branch 0 taken 167 times.
✗ Branch 1 not taken.
167 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14753 167 dir = down;
14754 167 hxofs=4;
14755 167 hit_width=8;
14756 // frate=17*4;
14757 167 fading=fade_blue_poof;
14758 //nets+5420;
14759
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 35 times.
167 if(get_qr(qr_NEWENEMYTILES))
14760 {
14761 /*
14762 necktile=o_tile+8;
14763 if (dmisc3)
14764 {
14765 necktile+=8;
14766 }
14767 */
14768 132 necktile=o_tile+dmisc6;
14769 132 }
14770 else
14771 {
14772 35 necktile=s_tile;
14773 }
14774 167 }
14775
14776 154537 bool eGleeok::animate(int32_t index)
14777 {
14778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154537 times.
154537 if(switch_hooked) return enemy::animate(index);
14779
2/2
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 152352 times.
154537 if(dying)
14780 2185 return Dead(index);
14781
14782
2/2
✓ Branch 0 taken 151671 times.
✓ Branch 1 taken 681 times.
152352 if(clk==0)
14783 {
14784 681 removearmos(x,y,ffcactivated);
14785 681 }
14786
14787 // Check if a head was killed somehow...
14788
2/2
✓ Branch 0 taken 101195 times.
✓ Branch 1 taken 51157 times.
152352 if(index+1+clk3>=guys.Count())
14789 51157 clk3=guys.Count()-index-1;
14790
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 86302 times.
152352 if(index+1+misc>=guys.Count())
14791 86302 misc=guys.Count()-index-1;
14792
14793 //fix for the "kill all enemies" item
14794
2/2
✓ Branch 0 taken 152346 times.
✓ Branch 1 taken 6 times.
152352 if(hp==-1000)
14795 {
14796
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14797 {
14798 // I haven't seen this fail, but it seems like it ought to be
14799 // possible, so I'm checking for it. - Saf
14800
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14801 break;
14802 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14803 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14804 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14805 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14806 12 }
14807
14808 6 clk3=0;
14809
14810
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14811 {
14812
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14813 break;
14814 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14815 12 }
14816 6 }
14817
14818
2/2
✓ Branch 0 taken 401281 times.
✓ Branch 1 taken 152352 times.
553633 for(int32_t i=0; i<clk3; i++)
14819 {
14820 401281 enemy *head = ((enemy*)guys.spr(index+i+1));
14821 401281 head->dummy_int[1]=necktile;
14822 401281 head->setParent(this);
14823
14824
2/2
✓ Branch 0 taken 318237 times.
✓ Branch 1 taken 83044 times.
401281 if(get_qr(qr_NEWENEMYTILES))
14825 {
14826 318237 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14827 318237 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14828 318237 }
14829 else
14830 {
14831 83044 head->dummy_int[2]=necktile+1; //connected head tile
14832 83044 head->dummy_int[3]=necktile+2; //flying head tile
14833 }
14834
14835 401281 head->dmisc5=dmisc5; //neck segments
14836
14837 /*
14838 if (dmisc3)
14839 {
14840 head->dummy_bool[0]=true;
14841 }
14842 */
14843
2/2
✓ Branch 0 taken 395686 times.
✓ Branch 1 taken 5595 times.
401281 if(head->hclk)
14844 {
14845
2/2
✓ Branch 0 taken 4380 times.
✓ Branch 1 taken 1215 times.
5595 if(hclk==0)
14846 {
14847 1215 hp -= 1000 - head->hp;
14848 1215 hclk = 33;
14849
14850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1215 times.
1215 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14851
14852 1215 sfx(WAV_EHIT,pan(int32_t(head->x)));
14853 1215 }
14854
14855 5595 head->hclk = 0;
14856 5595 }
14857
14858 // Must be set in case of naughty ZScripts
14859 401281 head->hp = 1000;
14860 401281 }
14861
14862
2/2
✓ Branch 0 taken 151941 times.
✓ Branch 1 taken 411 times.
152352 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14863 {
14864 411 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14865 411 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14866 411 }
14867
14868
2/2
✓ Branch 0 taken 56670 times.
✓ Branch 1 taken 95682 times.
152352 if(!dmisc3)
14869 {
14870
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14871 {
14872 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14873 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14874 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14875 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
14876 1287 clk2=0;
14877 1287 }
14878 95682 }
14879 else
14880 {
14881
4/4
✓ Branch 0 taken 2317 times.
✓ Branch 1 taken 54353 times.
✓ Branch 2 taken 1767 times.
✓ Branch 3 taken 550 times.
56670 if(++clk2>100 && !(zc_oldrand()&3))
14882 {
14883 550 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14884 550 head->timer=zc_oldrand()%50+50;
14885 550 clk2=0;
14886 550 }
14887 }
14888
14889
3/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 152226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
152352 if((hp<=0 && !immortal))
14890 {
14891
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 126 times.
512 for(int32_t i=0; i<misc; i++)
14892 386 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14893
14894
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 123 times.
126 if(flags&guy_never_return) never_return(screen_spawned, index);
14895 126 }
14896
14897 152352 return enemy::animate(index);
14898 154537 }
14899
14900 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14901 {
14902 1239 return 0;
14903 }
14904
14905 156165 void eGleeok::draw(BITMAP *dest)
14906 {
14907 156165 tile=o_tile;
14908
14909
2/2
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 153980 times.
156165 if(dying)
14910 {
14911 2185 enemy::draw(dest);
14912 2185 return;
14913 }
14914
14915 153980 int32_t f=clk/17;
14916
14917
2/2
✓ Branch 0 taken 119785 times.
✓ Branch 1 taken 34195 times.
153980 if(get_qr(qr_NEWENEMYTILES))
14918 {
14919 // body
14920 119785 xofs=-8;
14921 119785 yofs=32;
14922
14923
4/4
✓ Branch 0 taken 92002 times.
✓ Branch 1 taken 9104 times.
✓ Branch 2 taken 10044 times.
✓ Branch 3 taken 8635 times.
119785 switch(f)
14924
14925 {
14926 case 0:
14927 9104 tile+=0;
14928 9104 break;
14929
14930 case 1:
14931 10044 tile+=2;
14932 10044 break;
14933
14934 case 2:
14935 8635 tile+=4;
14936 8635 break;
14937
14938 default:
14939 92002 tile+=6;
14940 92002 break;
14941 }
14942 119785 }
14943 else
14944 {
14945 // body
14946 34195 xofs=-8;
14947 34195 yofs=32;
14948
14949
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14950 {
14951 case 0:
14952 2514 tile+=0;
14953 2514 break;
14954
14955 case 2:
14956 2459 tile+=4;
14957 2459 break;
14958
14959 default:
14960 29222 tile+=2;
14961 29222 break;
14962 }
14963 }
14964
14965 153980 enemy::drawblock(dest,15);
14966 156165 }
14967
14968 156165 void eGleeok::draw2(BITMAP *dest)
14969 {
14970 // the neck stub
14971 156165 tile=necktile;
14972 156165 xofs=0;
14973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156165 times.
156165 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14974
14975
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 121428 times.
156165 if(get_qr(qr_NEWENEMYTILES))
14976 {
14977 121428 tile+=((clk&24)>>3);
14978 121428 }
14979
14980
3/4
✓ Branch 0 taken 153980 times.
✓ Branch 1 taken 2185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153980 times.
156165 if(hp > 0 && !dont_draw())
14981 {
14982 153980 mapscr* scr = get_scr(screen_spawned);
14983
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149249 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
153980 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14984 737 sprite::drawcloaked(dest);
14985 else
14986 153243 sprite::draw(dest);
14987 153980 }
14988 156165 }
14989
14990
3/6
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 529 times.
✗ Branch 5 not taken.
1058 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14991 529 {
14992
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 setParent(prnt);
14993
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 xoffset=0;
14994
2/4
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
529 yoffset=(zfix)((dmisc5*4+2));
14995 // dummy_bool[0]=false;
14996 529 timer=0;
14997 /* fixing */
14998 529 hp=1000;
14999
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 step=1;
15000 529 item_set=0;
15001
4/8
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 529 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 529 times.
✗ Branch 7 not taken.
529 x = xoffset+parent->x;
15002
4/8
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 529 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 529 times.
✗ Branch 7 not taken.
529 y = yoffset+parent->y;
15003 529 hxofs=4;
15004 529 hit_width=8;
15005
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
529 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15006 529 clk2=clk; // how int32_t to wait before moving first time
15007 529 clk=0;
15008 529 mainguy=count_enemy=false;
15009
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 dir=zc_oldrand();
15010 529 clk3=((dir&2)>>1)+2; // left or right
15011 529 dir&=1; // up or down
15012
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 dmisc5=vbound(dmisc5,1,255);
15013 529 isCore = false;
15014
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 parentCore = parent->getUID();
15015
2/2
✓ Branch 0 taken 2116 times.
✓ Branch 1 taken 529 times.
2645 for(int32_t i=0; i<dmisc5; i++)
15016 {
15017 2116 nxoffset[i] = 0;
15018 2116 nyoffset[i] = 0;
15019
2/4
✓ Branch 0 taken 2116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2116 times.
✗ Branch 3 not taken.
2116 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15020
2/4
✓ Branch 0 taken 2116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2116 times.
✗ Branch 3 not taken.
2116 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15021 2116 }
15022
15023 529 necktile=0;
15024 //TODO compatibility? -DD
15025 /*
15026 for(int32_t i=0; i<4; i++)
15027 {
15028 nx[i]=124;
15029 ny[i]=i*6+48;
15030 }*/
15031 529 bgsfx=-1;
15032 //no need for deadsfx
15033 529 }
15034
15035 512579 bool esGleeok::animate(int32_t index)
15036 {
15037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512579 times.
512579 if(switch_hooked) return enemy::animate(index);
15038 // don't call removearmos() - it's a segment.
15039
15040 512579 dmisc5=vbound(dmisc5,1,255);
15041
15042
2/2
✓ Branch 0 taken 111703 times.
✓ Branch 1 taken 400876 times.
512579 if(misc == 0)
15043 {
15044 400876 x = (xoffset+parent->x);
15045 400876 y = (yoffset+parent->y);
15046
15047
2/2
✓ Branch 0 taken 1603504 times.
✓ Branch 1 taken 400876 times.
2004380 for(int32_t i=0; i<dmisc5; i++)
15048 {
15049 1603504 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15050 1603504 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15051 1603504 }
15052 400876 }
15053
15054 // set up the head tiles
15055 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15056 /*
15057 if (dummy_bool[0]) //if this is a flame gleeok
15058 {
15059 headtile+=180;
15060 }
15061 */
15062 512579 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15063 512579 flyingheadtile=dummy_int[3];
15064
15065 // set up the neck tiles
15066 512579 necktile=dummy_int[1];
15067
15068
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 399877 times.
512579 if(get_qr(qr_NEWENEMYTILES))
15069 {
15070 399877 necktile+=((clk&24)>>3);
15071 399877 }
15072
15073 /*
15074 else
15075 {
15076 necktile=145;
15077 }
15078 */
15079 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15080
15081
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 400876 times.
✓ Branch 2 taken 111008 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 398 times.
512579 switch(misc)
15082 {
15083 case 0: // live head
15084 // set up the attached head tiles
15085 400876 tile=headtile;
15086
15087
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 317934 times.
400876 if(get_qr(qr_NEWENEMYTILES))
15088 {
15089 317934 tile+=((clk&24)>>3);
15090 /*
15091 if (dummy_bool[0]) {
15092 tile+=1561;
15093 }
15094 */
15095 317934 }
15096
15097 /*
15098 else
15099 {
15100 tile=146;
15101 }
15102 */
15103
4/4
✓ Branch 0 taken 104000 times.
✓ Branch 1 taken 296876 times.
✓ Branch 2 taken 11568 times.
✓ Branch 3 taken 92432 times.
400876 if(++clk2>=0 && !(clk2&3))
15104 {
15105
2/2
✓ Branch 0 taken 90383 times.
✓ Branch 1 taken 2049 times.
92432 if(y<= (int32_t)parent->y + 8) dir=down;
15106
15107
2/2
✓ Branch 0 taken 90519 times.
✓ Branch 1 taken 1913 times.
92432 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15108
15109
4/4
✓ Branch 0 taken 9707 times.
✓ Branch 1 taken 82725 times.
✓ Branch 2 taken 9417 times.
✓ Branch 3 taken 290 times.
92432 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15110 {
15111 290 dir^=1;
15112 290 }
15113
15114 92432 zfix tempx = x;
15115 92432 zfix tempy = y;
15116
15117 92432 sprite::move(step);
15118 92432 xoffset += (x-tempx);
15119 92432 yoffset += (y-tempy);
15120
15121
2/2
✓ Branch 0 taken 3847 times.
✓ Branch 1 taken 88585 times.
92432 if(clk2>=4)
15122 {
15123 3847 clk3^=1;
15124 3847 clk2=-4;
15125 3847 }
15126 else
15127 {
15128
2/2
✓ Branch 0 taken 87612 times.
✓ Branch 1 taken 973 times.
88585 if(x <= (int32_t)parent->x-(dmisc5*6))
15129 {
15130 973 clk3=right;
15131 973 }
15132
15133
2/2
✓ Branch 0 taken 87627 times.
✓ Branch 1 taken 958 times.
88585 if(x >= (int32_t)parent->x+(dmisc5*6))
15134 {
15135 958 clk3=left;
15136 958 }
15137
15138
4/4
✓ Branch 0 taken 59759 times.
✓ Branch 1 taken 28826 times.
✓ Branch 2 taken 56061 times.
✓ Branch 3 taken 3698 times.
88585 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15139 {
15140 3698 clk3^=1; // x jig
15141 3698 }
15142 else
15143 {
15144
4/4
✓ Branch 0 taken 29072 times.
✓ Branch 1 taken 55815 times.
✓ Branch 2 taken 28225 times.
✓ Branch 3 taken 847 times.
84887 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15145 {
15146 847 clk3^=1; // x switch back
15147 847 }
15148
15149 84887 clk2=-4;
15150 }
15151 }
15152
15153 92432 zc_swap(dir,clk3);
15154 92432 tempx = x;
15155 92432 tempy = y;
15156 92432 sprite::move(step);
15157 92432 xoffset += (x-tempx);
15158 92432 yoffset += (y-tempy);
15159 92432 zc_swap(dir,clk3);
15160
15161
2/2
✓ Branch 0 taken 277296 times.
✓ Branch 1 taken 92432 times.
369728 for(int32_t i=1; i<dmisc5; i++)
15162 {
15163 277296 nxoffset[i] = (zc_oldrand()%3);
15164 277296 nyoffset[i] = (zc_oldrand()%3);
15165 277296 }
15166 92432 }
15167
15168 400876 break;
15169
15170 case 1: // flying head
15171
2/2
✓ Branch 0 taken 6520 times.
✓ Branch 1 taken 104488 times.
111008 if(clk>=0)
15172
15173 {
15174 104488 variable_walk_8(rate,homing,hrate,spw_floater);
15175 104488 }
15176
15177 111008 break;
15178
15179 // the following are messages sent from the main guy...
15180 case -1: // got chopped off
15181 {
15182 297 misc=1;
15183 297 superman=1;
15184 297 hxofs=xofs=0;
15185 297 hit_width=16;
15186 297 cs=8;
15187 297 clk=-24;
15188 297 clk2=40;
15189 297 dir=(zc_oldrand()&7)+8;
15190 297 step=8.0/9.0;
15191 }
15192 297 break;
15193
15194 case -2: // the big guy is dead
15195 398 return true;
15196 }
15197
15198
2/2
✓ Branch 0 taken 472536 times.
✓ Branch 1 taken 39645 times.
512181 if(timer)
15199 {
15200
2/2
✓ Branch 0 taken 34911 times.
✓ Branch 1 taken 4734 times.
39645 if(!(timer%8))
15201 {
15202 4734 FireBreath(true);
15203 4734 }
15204
15205 39645 --timer;
15206 39645 }
15207
15208 512181 return enemy::animate(index);
15209 512579 }
15210
15211 7007 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15212 {
15213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7007 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7007 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15214 {
15215 int32_t wpnId = w->id;
15216
15217 if(dying)
15218 return 0;
15219
15220 switch(wpnId)
15221 {
15222 case wLitBomb:
15223 case wLitSBomb:
15224 case wBait:
15225 case wWhistle:
15226 case wFire:
15227 case wWind:
15228 case wSSparkle:
15229 case wFSparkle:
15230 case wPhantom:
15231 return 0;
15232
15233 case wHookshot:
15234 case wBrang:
15235 case wBeam:
15236 case wArrow:
15237 case wMagic:
15238 case wBomb:
15239 case wSBomb:
15240 sfx(WAV_CHINK,pan(int32_t(x)));
15241 break;
15242 default:
15243 break;
15244 }
15245
15246 return 1;
15247 }
15248 else
15249 {
15250 7007 int32_t ret = enemy::takehit(w,realweap);
15251
15252
2/2
✓ Branch 0 taken 1412 times.
✓ Branch 1 taken 5595 times.
7007 if(ret==-1)
15253 5595 return -2; // force it to wait a frame before checking sword attacks again
15254
15255 1412 return ret;
15256 }
15257 7007 }
15258
15259 518500 void esGleeok::draw(BITMAP *dest)
15260 {
15261 518500 dmisc5=vbound(dmisc5,1,255);
15262
15263
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 407216 times.
✓ Branch 2 taken 111284 times.
518500 switch(misc)
15264 {
15265 case 0: //neck
15266
1/2
✓ Branch 0 taken 407216 times.
✗ Branch 1 not taken.
407216 if(!dont_draw())
15267 {
15268
2/2
✓ Branch 0 taken 1221648 times.
✓ Branch 1 taken 407216 times.
1628864 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15269 {
15270 1221648 mapscr* scr = get_scr(screen_spawned);
15271
2/2
✓ Branch 0 taken 972528 times.
✓ Branch 1 taken 249120 times.
1221648 if(get_qr(qr_NEWENEMYTILES))
15272 {
15273
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 949428 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
972528 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15274 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15275 else
15276 970317 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15277 972528 }
15278 else
15279 {
15280
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15281 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15282 else
15283 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15284 }
15285 1221648 }
15286 407216 }
15287
15288 407216 break;
15289
15290 case 1: //flying head
15291 111284 tile=flyingheadtile;
15292
15293
2/2
✓ Branch 0 taken 81626 times.
✓ Branch 1 taken 29658 times.
111284 if(get_qr(qr_NEWENEMYTILES))
15294 {
15295 81626 tile+=((clk&24)>>3);
15296 81626 break;
15297 }
15298 29658 }
15299 518500 }
15300
15301 518500 void esGleeok::draw2(BITMAP *dest)
15302 {
15303 518500 enemy::draw(dest);
15304 518500 }
15305
15306 189 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15307 189 {
15308
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ( !(editorflags & ENEMY_FLAG5) )
15309 {
15310
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 x = 128;
15311
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 y = 48;
15312 189 }
15313 else { x = X; y = Y; }
15314 189 adjusted=false;
15315
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 dir=(zc_oldrand()&7)+8;
15316 //step=0.25;
15317 189 flycnt=dmisc1;
15318 189 flycnt2=dmisc2;
15319 189 loopcnt=0;
15320 189 clk4 = 0;
15321 189 clk5 = 0;
15322 189 clk6 = 0;
15323 189 clk7 = 0;
15324
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc29 == 0)
15326 {
15327
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 104 times.
189 if(!dmisc4)
15328 {
15329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (dmisc10) dmisc29 = (90 / 3);
15330 104 else dmisc29 = (84 / 3);
15331 104 }
15332 else
15333 {
15334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15335 85 else dmisc29 = (84 / 2);
15336 }
15337 189 }
15338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc30 == 0)
15339 {
15340
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 104 times.
189 if(!dmisc4)
15341 {
15342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15343 104 else dmisc30 = (84 / 3)*0.5;
15344 104 }
15345 else
15346 {
15347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15348 85 else dmisc30 = (84 / 2)*0.5;
15349 }
15350 189 }
15351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc31 == 0)
15352 {
15353
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 104 times.
189 if(!dmisc4)
15354 {
15355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (dmisc10) dmisc31 = (90 / 3)*2;
15356 104 else dmisc31 = (84 / 3)*2;
15357 104 }
15358 else
15359 {
15360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15361 85 else dmisc31 = (84 / 2)*0.5;
15362 }
15363 189 }
15364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc32 == 0)
15365 {
15366
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 104 times.
189 if(!dmisc4)
15367 {
15368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (dmisc10) dmisc32 = (90 / 3);
15369 104 else dmisc32 = (84 / 3);
15370 104 }
15371 else
15372 {
15373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15374 85 else dmisc32 = (84 / 2)*0.25;
15375 }
15376 189 }
15377
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 init_size_flags();
15378 189 }
15379
15380 159317 bool ePatra::animate(int32_t index)
15381 {
15382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159317 times.
159317 if(switch_hooked) return enemy::animate(index);
15383
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 157887 times.
159317 if(dying)
15384 {
15385
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1430 times.
1502 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15386 {
15387 72 auto segment = (enemy*)guys.spr(i);
15388
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15389 72 segment->hp = -1000;
15390 72 }
15391
15392 1430 return Dead(index);
15393 }
15394
15395 157887 double basesize = 84;
15396
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 if (dmisc10) basesize = 90;
15397 157887 double halfsize = basesize / 2;
15398 157887 double quartersize = halfsize / 2;
15399 157887 double twothirdsize = (basesize / 3)*2;
15400 157887 double onethirdsize = (basesize / 3);
15401
15402
15403
2/2
✓ Branch 0 taken 121588 times.
✓ Branch 1 taken 36299 times.
157887 if(clk==0)
15404 {
15405 36299 removearmos(x,y,ffcactivated);
15406 36299 }
15407
15408
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 157887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 157887 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
157887 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15409 {
15410
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 157887 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
157887 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15411
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 if (loopcnt < 0) ++clk2;
15412
2/2
✓ Branch 0 taken 156120 times.
✓ Branch 1 taken 1767 times.
157887 if(++clk2>basesize)
15413 {
15414 1767 clk2=0;
15415
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1767 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1767 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15416 {
15417
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 850 times.
1767 if(loopcnt > 0)
15418 917 --loopcnt;
15419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 850 times.
850 else if (loopcnt == 0)
15420 {
15421
2/2
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 351 times.
850 if (zc::math::SafeMod(misc, dmisc6) == 0)
15422 {
15423
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 if (dmisc21 > 0) loopcnt=-dmisc21;
15424 351 else loopcnt=dmisc7;
15425 351 }
15426 850 }
15427 else if (loopcnt == -1) loopcnt=dmisc7;
15428 else ++loopcnt;
15429
15430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1767 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15431 1767 }
15432 else
15433 {
15434 loopcnt = 0;
15435 misc = 1;
15436 }
15437 1767 }
15438 157887 }
15439
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 if (clk4 > 0) --clk4;
15440
15441
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 if (clk6 < 0)
15442 {
15443 if (dmisc5 == 1 || dmisc5 == 3)
15444 {
15445 if (get_qr(qr_NEWENEMYTILES))
15446 {
15447 if (clk7 <= 0 || clk6 != -16) ++clk6;
15448 if (clk6 == 0) o_tile=d->e_tile;
15449 else
15450 {
15451 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15452 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15453 }
15454 }
15455 else clk6 = 0;
15456 }
15457 }
15458
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 else if (dmisc19) ++clk6;
15459
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 if (clk5 < 0) ++clk5;
15460
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 else if (dmisc19) ++clk5;
15461
15462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 157887 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
157887 if (clk7 > 0 && clk6 >= -16) --clk7;
15463
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 if (clk6 > 0) clk7 = 0;
15464
15465
2/2
✓ Branch 0 taken 655766 times.
✓ Branch 1 taken 157887 times.
813653 for(int32_t i=index+1; i<index+flycnt+1; i++)
15466 {
15467 //outside ring
15468
2/2
✓ Branch 0 taken 654430 times.
✓ Branch 1 taken 1336 times.
655766 if(!adjusted)
15469 {
15470
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 192 times.
1336 if(get_qr(qr_NEWENEMYTILES))
15471 {
15472 1144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15473 1144 enemy *s = ((enemy*)guys.spr(i));
15474 1144 s->setParent(this);
15475 1144 }
15476 else
15477 {
15478 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15479 192 enemy *s = ((enemy*)guys.spr(i));
15480 192 s->setParent(this);
15481 }
15482
15483 1336 ((enemy*)guys.spr(i))->cs=dmisc9;
15484 1336 ((enemy*)guys.spr(i))->hp=dmisc3;
15485 1336 }
15486
15487
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 655010 times.
655766 if(((enemy*)guys.spr(i))->hp <= 0)
15488 {
15489
2/2
✓ Branch 0 taken 2810 times.
✓ Branch 1 taken 756 times.
3566 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15490 {
15491 2810 guys.swap(j,j+1);
15492 2810 }
15493
15494
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 663 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
756 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15495 756 }
15496 else
15497 {
15498 655010 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15499
1/2
✓ Branch 0 taken 655010 times.
✗ Branch 1 not taken.
655010 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15500
15501
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 442973 times.
655010 if(!dmisc4) //Big Ring
15502 {
15503 //maybe playing_field_offset here?
15504
2/2
✓ Branch 0 taken 235025 times.
✓ Branch 1 taken 207948 times.
442973 if(loopcnt>0)
15505 {
15506
1/2
✓ Branch 0 taken 235025 times.
✗ Branch 1 not taken.
235025 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15507
1/2
✓ Branch 0 taken 235025 times.
✗ Branch 1 not taken.
235025 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15508 235025 }
15509 else
15510 {
15511 207948 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15512 207948 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15513 }
15514
15515 442973 temp_x=guys.spr(i)->x;
15516 442973 temp_y=guys.spr(i)->y;
15517 442973 }
15518 else //Oval
15519 {
15520 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15521 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15522
15523
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15524 {
15525 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15526
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15527 121041 }
15528 else
15529 {
15530 90996 guys.spr(i)->x = circle_x;
15531 90996 guys.spr(i)->y = circle_y;
15532 }
15533
15534 212037 temp_x=circle_x;
15535 212037 temp_y=circle_y;
15536 }
15537
15538 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15539 655010 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15540
15541
4/4
✓ Branch 0 taken 123162 times.
✓ Branch 1 taken 531848 times.
✓ Branch 2 taken 40617 times.
✓ Branch 3 taken 82545 times.
655010 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15542 {
15543 82545 guys.spr(i)->dir=l_down;
15544 82545 }
15545
4/4
✓ Branch 0 taken 123631 times.
✓ Branch 1 taken 448834 times.
✓ Branch 2 taken 40617 times.
✓ Branch 3 taken 83014 times.
572465 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15546 {
15547 83014 guys.spr(i)->dir=left;
15548 83014 }
15549
4/4
✓ Branch 0 taken 122519 times.
✓ Branch 1 taken 366932 times.
✓ Branch 2 taken 40617 times.
✓ Branch 3 taken 81902 times.
489451 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15550 {
15551 81902 guys.spr(i)->dir=l_up;
15552 81902 }
15553
4/4
✓ Branch 0 taken 122256 times.
✓ Branch 1 taken 285293 times.
✓ Branch 2 taken 40617 times.
✓ Branch 3 taken 81639 times.
407549 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15554 {
15555 81639 guys.spr(i)->dir=up;
15556 81639 }
15557
4/4
✓ Branch 0 taken 121642 times.
✓ Branch 1 taken 204268 times.
✓ Branch 2 taken 40617 times.
✓ Branch 3 taken 81025 times.
325910 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15558 {
15559 81025 guys.spr(i)->dir=r_up;
15560 81025 }
15561
4/4
✓ Branch 0 taken 121996 times.
✓ Branch 1 taken 122889 times.
✓ Branch 2 taken 40617 times.
✓ Branch 3 taken 81379 times.
244885 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15562 {
15563 81379 guys.spr(i)->dir=right;
15564 81379 }
15565
4/4
✓ Branch 0 taken 121709 times.
✓ Branch 1 taken 41797 times.
✓ Branch 2 taken 40617 times.
✓ Branch 3 taken 81092 times.
163506 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15566 {
15567 81092 guys.spr(i)->dir=r_down;
15568 81092 }
15569 else
15570 {
15571 82414 guys.spr(i)->dir=down;
15572 }
15573
15574 655010 guys.spr(i)->x += x;
15575 655010 guys.spr(i)->y += y;
15576 }
15577 655766 }
15578
15579
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 50930 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 29777 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 29777 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
157887 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15580 {
15581 29777 int timeneeded = 48;
15582 29777 int patbreath = (zc_oldrand()%50+50);
15583
2/2
✓ Branch 0 taken 22595 times.
✓ Branch 1 taken 7182 times.
29777 if ((patbreath % 4) == 0) ++patbreath;
15584
1/2
✓ Branch 0 taken 29777 times.
✗ Branch 1 not taken.
29777 if (dmisc28 == patratBREATH)
15585 {
15586 timeneeded = 48 + patbreath;
15587 }
15588
1/2
✓ Branch 0 taken 29777 times.
✗ Branch 1 not taken.
29777 if (dmisc28 == patratSTREAM)
15589 {
15590 timeneeded = 48 + 96;
15591 }
15592
4/14
✓ Branch 0 taken 29777 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29777 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 235 times.
✓ Branch 11 taken 235 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
29777 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15593
2/2
✓ Branch 0 taken 29777 times.
✓ Branch 1 taken 235 times.
30012 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15594
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 29542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
30012 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15595 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15596 235 && (clk6 >= 0) //if not in the middle of firing...
15597 235 && clk6 >= dmisc19) //if over the set cooldown between shots...
15598
2/6
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 235 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
235 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15599 {
15600
1/3
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
235 switch(dmisc28)
15601 {
15602 case patratSTREAM:
15603 {
15604 clk7 = 97;
15605 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15606 else clk6 = 0;
15607 break;
15608 }
15609 case patratBREATH:
15610 {
15611 clk7 = patbreath;
15612 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15613 else clk6 = 0;
15614 break;
15615 }
15616 default:
15617 {
15618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 235 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
235 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15619 {
15620 clk6 = -48;
15621 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15622 }
15623 else
15624 {
15625 235 clk6 = 0;
15626
1/2
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
235 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15627 235 FirePatraWeapon();
15628 }
15629 235 break;
15630 }
15631 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15632 235 }
15633
1/2
✓ Branch 0 taken 29777 times.
✗ Branch 1 not taken.
29777 if (clk6 < 0)
15634 {
15635 switch(dmisc28)
15636 {
15637 case patratSTREAM:
15638 {
15639 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15640 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15641 break;
15642 }
15643 case patratBREATH:
15644 {
15645 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15646 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15647 break;
15648 }
15649 default:
15650 {
15651 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15652 {
15653 FirePatraWeapon();
15654 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15655 }
15656 break;
15657 }
15658 }
15659 }
15660 29777 }
15661
15662 157887 int randattempts = 0;
15663 157887 int randeye = 0;
15664
2/2
✓ Branch 0 taken 114011 times.
✓ Branch 1 taken 43876 times.
157887 if (flycnt2 > 0)
15665 {
15666 43876 do
15667 {
15668
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43876 times.
✓ Branch 2 taken 42462 times.
✓ Branch 3 taken 1414 times.
43876 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15669 43876 randeye += (index + flycnt + 1);
15670 43876 ++randattempts;
15671
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43876 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43876 times.
43876 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15672 43876 }
15673 157887 bool dofire = false;
15674
1/2
✓ Branch 0 taken 157887 times.
✗ Branch 1 not taken.
157887 if (dmisc20)
15675 {
15676 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15677 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15678 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15679 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15680 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15681 {
15682 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15683 {
15684 if (clk5 >= dmisc19)
15685 {
15686 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15687 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15688 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15689 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15690 || dmisc18 == -1)
15691 dofire = true;
15692 }
15693 }
15694 }
15695 }
15696
2/2
✓ Branch 0 taken 114011 times.
✓ Branch 1 taken 43876 times.
157887 if(flycnt2)
15697 {
15698
2/2
✓ Branch 0 taken 321917 times.
✓ Branch 1 taken 43876 times.
365793 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15699 {
15700
2/2
✓ Branch 0 taken 321613 times.
✓ Branch 1 taken 304 times.
321917 if(!adjusted)
15701 {
15702 304 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15703
15704
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(get_qr(qr_NEWENEMYTILES))
15705 {
15706
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15707 {
15708
2/3
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
304 switch(dmisc5)
15709 {
15710 // Center eye shoots projectiles; make room for its firing tiles
15711 case 1:
15712 case 3:
15713 136 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15714 136 break;
15715
15716 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15717 default:
15718 case 2:
15719 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15720 168 break;
15721 }
15722 304 }
15723 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15724 304 }
15725 else
15726 {
15727 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15728 }
15729
15730 304 ((enemy*)guys.spr(i))->cs=dmisc9;
15731
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15732 304 }
15733
15734
2/2
✓ Branch 0 taken 257920 times.
✓ Branch 1 taken 63997 times.
321917 if(flycnt>0)
15735 {
15736 257920 ((enemy*)guys.spr(i))->superman=true;
15737 257920 }
15738 else
15739 {
15740 63997 ((enemy*)guys.spr(i))->superman=false;
15741 }
15742
15743
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 321780 times.
321917 if(((enemy*)guys.spr(i))->hp <= 0)
15744 {
15745
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 137 times.
397 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15746 {
15747 260 guys.swap(j,j+1);
15748 260 }
15749
15750
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
137 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15751 137 }
15752 else
15753 {
15754 321780 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15755
1/2
✓ Branch 0 taken 321780 times.
✗ Branch 1 not taken.
321780 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15756
15757
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 314521 times.
321780 if(dmisc4==0)
15758 {
15759
2/2
✓ Branch 0 taken 161908 times.
✓ Branch 1 taken 152613 times.
314521 if(loopcnt>0)
15760 {
15761
1/2
✓ Branch 0 taken 161908 times.
✗ Branch 1 not taken.
161908 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15762
1/2
✓ Branch 0 taken 161908 times.
✗ Branch 1 not taken.
161908 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15763 161908 }
15764 else
15765 {
15766 152613 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15767 152613 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15768 }
15769
15770 314521 temp_x=guys.spr(i)->x;
15771 314521 temp_y=guys.spr(i)->y;
15772 314521 }
15773 else
15774 {
15775 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15776 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15777
15778
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15779 {
15780 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15781
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15782 3965 }
15783 else
15784 {
15785 3294 guys.spr(i)->x = circle_x;
15786 3294 guys.spr(i)->y = circle_y;
15787 }
15788
15789 7259 temp_x=circle_x;
15790 7259 temp_y=circle_y;
15791 }
15792
15793 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15794 321780 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15795
15796
4/4
✓ Branch 0 taken 59403 times.
✓ Branch 1 taken 262377 times.
✓ Branch 2 taken 19153 times.
✓ Branch 3 taken 40250 times.
321780 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15797 {
15798 40250 guys.spr(i)->dir=l_down;
15799 40250 }
15800
4/4
✓ Branch 0 taken 59375 times.
✓ Branch 1 taken 222155 times.
✓ Branch 2 taken 19153 times.
✓ Branch 3 taken 40222 times.
281530 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15801 {
15802 40222 guys.spr(i)->dir=left;
15803 40222 }
15804
4/4
✓ Branch 0 taken 59353 times.
✓ Branch 1 taken 181955 times.
✓ Branch 2 taken 19153 times.
✓ Branch 3 taken 40200 times.
241308 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15805 {
15806 40200 guys.spr(i)->dir=l_up;
15807 40200 }
15808
4/4
✓ Branch 0 taken 59330 times.
✓ Branch 1 taken 141778 times.
✓ Branch 2 taken 19153 times.
✓ Branch 3 taken 40177 times.
201108 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15809 {
15810 40177 guys.spr(i)->dir=up;
15811 40177 }
15812
4/4
✓ Branch 0 taken 59364 times.
✓ Branch 1 taken 101567 times.
✓ Branch 2 taken 19153 times.
✓ Branch 3 taken 40211 times.
160931 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15813 {
15814 40211 guys.spr(i)->dir=r_up;
15815 40211 }
15816
4/4
✓ Branch 0 taken 59366 times.
✓ Branch 1 taken 61354 times.
✓ Branch 2 taken 19153 times.
✓ Branch 3 taken 40213 times.
120720 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15817 {
15818 40213 guys.spr(i)->dir=right;
15819 40213 }
15820
4/4
✓ Branch 0 taken 59413 times.
✓ Branch 1 taken 21094 times.
✓ Branch 2 taken 19153 times.
✓ Branch 3 taken 40260 times.
80507 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15821 {
15822 40260 guys.spr(i)->dir=r_down;
15823 40260 }
15824 else
15825 {
15826 40247 guys.spr(i)->dir=down;
15827 }
15828
15829 321780 guys.spr(i)->x += x;
15830 321780 guys.spr(i)->y = y-guys.spr(i)->y;
15831
15832
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 321780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 176512 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 176512 times.
321780 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15833 {
15834 /*
15835 if(!(zc_oldrand()&127))
15836 {
15837 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15838 sfx(wpnsfx(wpn),pan(int32_t(x)));
15839 }
15840 */
15841
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15842 {
15843 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15844 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15845 {
15846 if (dmisc5 == 3)
15847 {
15848 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15849 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15850 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15851 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15852 }
15853 else
15854 {
15855 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15856 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15857 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15858 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15859 }
15860 }
15861 else
15862 {
15863 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15864 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15865 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15866 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15867 }
15868 }
15869
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15870
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15871
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15872 {
15873
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15874 {
15875 case 4: //Single one rapidfires
15876 {
15877 if (dofire && i == randeye)
15878 {
15879 ((esPatra*)guys.spr(i))->clk5 = -16;
15880 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15881 ((esPatra*)guys.spr(i))->clk4 = 96;
15882 clk5 = -3;
15883 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15884 }
15885 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15886 {
15887 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15888 sfx(wpnsfx(wpn),pan(int32_t(x)));
15889 }
15890 break;
15891 }
15892 case 3: //Ring
15893 {
15894 if (dofire)
15895 {
15896 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15897 {
15898 ((esPatra*)guys.spr(i))->clk5 = -48;
15899 clk5 = -48;
15900 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15901 }
15902 else
15903 {
15904 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15905 sfx(wpnsfx(wpn),pan(int32_t(x)));
15906 int32_t m=Ewpns.Count()-1;
15907 weapon *ew = (weapon*)(Ewpns.spr(m));
15908
15909 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15910 ((esPatra*)guys.spr(i))->clk5 = 0;
15911 clk5 = 0;
15912 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15913 }
15914 }
15915 if (((esPatra*)guys.spr(i))->clk5 == -16)
15916 {
15917 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15918 sfx(wpnsfx(wpn),pan(int32_t(x)));
15919 int32_t m=Ewpns.Count()-1;
15920 weapon *ew = (weapon*)(Ewpns.spr(m));
15921
15922 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15923 }
15924 break;
15925 }
15926 case 2: //one after another
15927 {
15928 if (dofire)
15929 {
15930 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15931 clk5 = -48 - (12*flycnt2);
15932 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15933 }
15934 if (((esPatra*)guys.spr(i))->clk5 == -16)
15935 {
15936 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15937 sfx(wpnsfx(wpn),pan(int32_t(x)));
15938 }
15939 break;
15940 }
15941 case 1: //random one eye
15942 {
15943 if (dofire && i == randeye)
15944 {
15945 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15946 {
15947 ((esPatra*)guys.spr(i))->clk5 = -48;
15948 clk5 = -48;
15949 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15950 }
15951 else
15952 {
15953 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15954 sfx(wpnsfx(wpn),pan(int32_t(x)));
15955 ((esPatra*)guys.spr(i))->clk5 = 0;
15956 clk5 = 0;
15957 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15958 }
15959 }
15960 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15961 {
15962 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15963 sfx(wpnsfx(wpn),pan(int32_t(x)));
15964 }
15965 break;
15966 }
15967 default: //old behavior, all eyes can fire any time
15968 {
15969
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15970
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15971
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15972 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15973 {
15974
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15975 {
15976 ((esPatra*)guys.spr(i))->clk5 = -48;
15977 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15978 }
15979 else
15980 {
15981 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15982 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
15983 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15984
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15985 }
15986 1155 }
15987
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15988 {
15989 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15990 sfx(wpnsfx(wpn),pan(int32_t(x)));
15991 }
15992 145268 break;
15993 }
15994 }
15995 145268 }
15996 145268 }
15997
15998 }
15999 321917 }
16000 43876 }
16001
16002 157887 adjusted=true;
16003 157887 return enemy::animate(index);
16004 159317 }
16005
16006 235 void ePatra::FirePatraWeapon()
16007 { //.707
16008 235 int32_t xoff = 0;
16009 235 int32_t yoff = 0;
16010
1/2
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
235 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16011 {
16012 xoff += hxofs;
16013 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
16014 xoff += (hit_width / 2) - (weap_data.tilew * 8);
16015 else
16016 xoff += (hit_width / 2) - 8;
16017 }
16018
1/2
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
235 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16019 {
16020 yoff += hyofs;
16021 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
16022 yoff += (hit_height / 2) - (weap_data.tileh * 8);
16023 else
16024 yoff += (hit_height / 2) - 8;
16025 }
16026 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
16027 // TODO(crash): check that .add succeeds.
16028
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 235 times.
235 switch (dmisc28)
16029 {
16030 case patrat8SHOT: //Fire Wizzrobe
16031 case patrat4SHOTDIAG:
16032 case patrat4SHOTRAND:
16033 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16034 {
16035 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16037 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16038 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16039
16040 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16041 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16042 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16043 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16044
16045 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16047 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16048 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16049
16050 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16051 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16052 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16053 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16054
16055 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16056 }
16057
16058 [[fallthrough]];
16059 case patrat4SHOTCARD: //Stalfos 3
16060 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16061 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16062 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16063 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16064 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16065 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16066 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16068 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16069 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16070 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16072 break;
16073
16074 default:
16075 235 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16076
1/2
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
235 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16077 235 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16078
3/6
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 235 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 235 times.
235 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16079
4/8
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 235 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 235 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 235 times.
235 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16080 {
16081 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16082 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16083 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16084 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16085 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16086 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16087 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16088 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16089 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16090 {
16091 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16092 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16093 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16094 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16095 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16096 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16097 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16098 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16099 }
16100 }
16101 235 break;
16102
16103 }
16104 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
16105 //+0.46364761
16106 //11.80
16107 235 }
16108
16109 319106 void ePatra::draw(BITMAP *dest)
16110 {
16111 319106 tile=o_tile;
16112 319106 update_enemy_frame();
16113 319106 enemy::draw(dest);
16114 319106 }
16115
16116 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16117 {
16118 int32_t ret = enemy::defend(wpnId, power, edef);
16119
16120 if(ret < 0 && (flycnt||flycnt2))
16121 return 0;
16122
16123 return ret;
16124 }
16125
16126 1723 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16127 {
16128 1723 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16129
16130
6/6
✓ Branch 0 taken 1603 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 769 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 443 times.
✓ Branch 5 taken 326 times.
1723 if(ret < 0 && (flycnt||flycnt2))
16131 1277 return 0;
16132
16133 446 return ret;
16134 1723 }
16135
16136 189 void ePatra::init_size_flags() {
16137 189 SIZEflags = d->SIZEflags;
16138
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
189 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16139
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16140 // al_trace("Enemy txsz:%i\n", txsz);
16141
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
189 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16142
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16144
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) hit_width = 32;
16145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16148
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) hxofs = -8;
16149
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16150 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16152
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) xofs = -8;
16153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16154 {
16155 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16156 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16157 }
16158
1/4
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16159
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if (editorflags & ENEMY_FLAG8) misc = 1;
16160
16161
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16162
16163 189 }
16164
16165 1640 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16166 1640 {
16167 //cs=8;
16168
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 setParent(prnt);
16169 1640 item_set=0;
16170 1640 misc=clk;
16171 1640 clk4 = 0;
16172 1640 clk5 = 0;
16173 1640 clk = -((misc*21)>>1)-1;
16174
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
1640 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16175 1640 hit_width=12;
16176 1640 hit_height=12;
16177 1640 hxofs=2;
16178 1640 hyofs=2;
16179 1640 extend = 0;
16180 1640 txsz = 1;
16181 1640 tysz = 1;
16182 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16183 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16184 int32_t prntSIZEflags = prntenemy->SIZEflags;
16185 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16186 // al_trace("Enemy txsz:%i\n", txsz);
16187 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16188 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16189 else
16190 hxsz=12;
16191 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16192 else
16193 hysz=12;
16194 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16195 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16196 else
16197 hxofs=2;
16198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16199 else hyofs=2;
16200 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16201 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16202 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16203 {
16204 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16205 }
16206
16207 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16208 */
16209 1640 mainguy=count_enemy=false;
16210 1640 bgsfx=-1;
16211 //o_tile=0;
16212
2/4
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
1640 flags &= (~guy_never_return);
16213 1640 deadsfx = WAV_EDEAD;
16214 1640 hitsfx = WAV_EHIT;
16215 1640 isCore = false;
16216 1640 }
16217
16218 993219 bool esPatra::animate(int32_t index)
16219 {
16220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993219 times.
993219 if(switch_hooked) return enemy::animate(index);
16221
2/2
✓ Branch 0 taken 14936 times.
✓ Branch 1 taken 978283 times.
993219 if(dying)
16222 14936 return Dead(index);
16223
16224 978283 return enemy::animate(index);
16225 993219 }
16226
16227 1993466 void esPatra::draw(BITMAP *dest)
16228 {
16229
2/2
✓ Branch 0 taken 1686564 times.
✓ Branch 1 taken 306902 times.
1993466 if(get_qr(qr_NEWENEMYTILES))
16230 {
16231 1686564 tile = o_tile+(clk&3);
16232
16233
8/9
✓ Branch 0 taken 209944 times.
✓ Branch 1 taken 213642 times.
✓ Branch 2 taken 211094 times.
✓ Branch 3 taken 211154 times.
✓ Branch 4 taken 208816 times.
✓ Branch 5 taken 209876 times.
✓ Branch 6 taken 211568 times.
✓ Branch 7 taken 210470 times.
✗ Branch 8 not taken.
1686564 switch(dir) //directions get screwed up after 8. *shrug*
16234 {
16235 case up: //u
16236 209944 flip=0;
16237 209944 break;
16238
16239 case down: //d
16240 213642 flip=0;
16241 213642 tile+=4;
16242 213642 break;
16243
16244 case left: //l
16245 211094 flip=0;
16246 211094 tile+=8;
16247 211094 break;
16248
16249 case right: //r
16250 211154 flip=0;
16251 211154 tile+=12;
16252 211154 break;
16253
16254 case l_up: //ul
16255 208816 flip=0;
16256 208816 tile+=20;
16257 208816 break;
16258
16259 case r_up: //ur
16260 209876 flip=0;
16261 209876 tile+=24;
16262 209876 break;
16263
16264 case l_down: //dl
16265 211568 flip=0;
16266 211568 tile+=28;
16267 211568 break;
16268
16269 case r_down: //dr
16270 210470 flip=0;
16271 210470 tile+=32;
16272 210470 break;
16273 }
16274 1686564 }
16275 else
16276 {
16277 306902 tile = o_tile+((clk&2)>>1);
16278 }
16279
16280
2/2
✓ Branch 0 taken 113656 times.
✓ Branch 1 taken 1879810 times.
1993466 if(clk>=0)
16281 1879810 enemy::draw(dest);
16282 1993466 }
16283
16284
16285 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16286 102 {
16287 102 adjusted=false;
16288
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16289
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16290 102 clk4 = 0;
16291 102 clk5 = 0;
16292 //flycnt=6; flycnt2=0;
16293 102 flycnt=dmisc1;
16294 102 flycnt2=0; // PatraBS doesn't have inner rings!
16295 102 loopcnt=0;
16296
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16298
16299 //nets+4480;
16300 102 }
16301
16302 35963 bool ePatraBS::animate(int32_t index)
16303 {
16304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16305
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16306 240 return Dead(index);
16307
16308
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16309 {
16310 4018 removearmos(x,y,ffcactivated);
16311 4018 }
16312
16313 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16314
16315
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16316 {
16317 336 clk2=0;
16318
16319
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16320 177 --loopcnt;
16321 else
16322 {
16323
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16324 84 loopcnt=dmisc7;
16325 }
16326
16327 336 ++misc;
16328 336 }
16329
16330 // double size=1;;
16331
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16332 {
16333
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16334 {
16335 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16336
16337
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16338 {
16339 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16340 612 }
16341 else
16342 {
16343 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16344 }
16345
16346 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16347 612 }
16348
16349
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16350 {
16351
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16352 {
16353 131 guys.swap(j,j+1);
16354 131 }
16355
16356 104 --flycnt;
16357 104 }
16358 else
16359 {
16360 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16361
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16362 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16363 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16364
16365
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16366 {
16367 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16368
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16369 77643 }
16370 else
16371 {
16372 75725 guys.spr(i)->x = temp_x;
16373 75725 guys.spr(i)->y = temp_y;
16374 }
16375
16376 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16377 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16378
16379
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16380 {
16381 18812 guys.spr(i)->dir=l_down;
16382 18812 }
16383
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16384 {
16385 18839 guys.spr(i)->dir=left;
16386 18839 }
16387
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16388 {
16389 18802 guys.spr(i)->dir=l_up;
16390 18802 }
16391
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16392 {
16393 20143 guys.spr(i)->dir=up;
16394 20143 }
16395
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16396 {
16397 18517 guys.spr(i)->dir=r_up;
16398 18517 }
16399
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16400 {
16401 18779 guys.spr(i)->dir=right;
16402 18779 }
16403
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16404 {
16405 18992 guys.spr(i)->dir=r_down;
16406 18992 }
16407 else
16408 {
16409 20484 guys.spr(i)->dir=down;
16410 }
16411
16412 153368 guys.spr(i)->x += x;
16413 153368 guys.spr(i)->y += y;
16414 }
16415 153472 }
16416
16417 35723 adjusted=true;
16418 35723 return enemy::animate(index);
16419 35963 }
16420
16421 72874 void ePatraBS::draw(BITMAP *dest)
16422 {
16423 72874 tile=o_tile;
16424
16425
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16426 {
16427 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16428 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16429
16430
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16431 {
16432 19146 lookat=l_down;
16433 19146 }
16434
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16435 {
16436 18298 lookat=down;
16437 18298 }
16438
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16439 {
16440 13624 lookat=r_down;
16441 13624 }
16442
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16443 {
16444 7492 lookat=right;
16445 7492 }
16446
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16447 {
16448 1170 lookat=r_up;
16449 1170 }
16450
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16451 {
16452 964 lookat=up;
16453 964 }
16454
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16455 {
16456 1700 lookat=l_up;
16457 1700 }
16458 else
16459 {
16460 10480 lookat=left;
16461 }
16462
16463
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16464 {
16465 case up: //u
16466 964 flip=0;
16467 964 break;
16468
16469 case down: //d
16470 18298 flip=0;
16471 18298 tile+=8;
16472 18298 break;
16473
16474 case left: //l
16475 10480 flip=0;
16476 10480 tile+=40;
16477 10480 break;
16478
16479 case right: //r
16480 7492 flip=0;
16481 7492 tile+=48;
16482 7492 break;
16483
16484 case l_up: //ul
16485 1700 flip=0;
16486 1700 tile+=80;
16487 1700 break;
16488
16489 case r_up: //ur
16490 1170 flip=0;
16491 1170 tile+=88;
16492 1170 break;
16493
16494 case l_down: //dl
16495 19146 flip=0;
16496 19146 tile+=120;
16497 19146 break;
16498
16499 case r_down: //dr
16500 13624 flip=0;
16501 13624 tile+=128;
16502 13624 break;
16503 }
16504
16505 72874 tile+=(2*(clk&3));
16506 72874 xofs-=8;
16507 72874 yofs-=8;
16508 72874 drawblock(dest,15);
16509 72874 xofs+=8;
16510 72874 yofs+=8;
16511 72874 }
16512 else
16513 {
16514 flip=(clk&1);
16515 xofs-=8;
16516 yofs-=8;
16517 enemy::draw(dest);
16518 xofs+=16;
16519 enemy::draw(dest);
16520 yofs+=16;
16521 enemy::draw(dest);
16522 xofs-=16;
16523 enemy::draw(dest);
16524 xofs+=8;
16525 yofs-=8;
16526 }
16527 72874 }
16528
16529 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16530 {
16531 int32_t ret = enemy::defend(wpnId, power, edef);
16532
16533 if(ret < 0 && (flycnt||flycnt2))
16534 return 0;
16535
16536 return ret;
16537 }
16538
16539 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16540 {
16541 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16542
16543
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16544 81 return 0;
16545
16546 61 return ret;
16547 142 }
16548
16549 102 void ePatraBS::init_size_flags()
16550 {
16551 102 SIZEflags = d->SIZEflags;
16552
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16553 // al_trace("Enemy txsz:%i\n", txsz);
16554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16556 102 else hit_width = 32;
16557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16560 102 else hxofs = -8;
16561
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16562 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16563
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16564
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16565 {
16566 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16567 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16568 }
16569
16570
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16571 102 }
16572
16573 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16574 612 {
16575 //cs=csBOSS;
16576
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16577 612 item_set=0;
16578 612 misc=clk;
16579 612 clk = -((misc*21)>>1)-1;
16580 612 clk4 = 0;
16581 612 clk5 = 0;
16582
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16583 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16584
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16585 // al_trace("Enemy txsz:%i\n", txsz);
16586
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16587
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16588 612 else hit_width=16;
16589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16590 612 else hit_height=16;
16591
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16592
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16594 612 else hyofs=2;
16595 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16596
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16598 {
16599 yofs = (int32_t)prntenemy->yofs;
16600 }
16601
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16602
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16603
16604 612 bgsfx=-1;
16605 612 mainguy=count_enemy=false;
16606 612 deadsfx = WAV_EDEAD;
16607 612 hitsfx = WAV_EHIT;
16608
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16609 612 isCore = false;
16610 612 }
16611
16612 155090 bool esPatraBS::animate(int32_t index)
16613 {
16614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16615
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16616 1552 return Dead(index);
16617
16618 153538 return enemy::animate(index);
16619 155090 }
16620
16621 315868 void esPatraBS::draw(BITMAP *dest)
16622 {
16623 315868 tile=o_tile;
16624
16625
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16626 {
16627
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16628 {
16629 case up: //u
16630 41612 flip=0;
16631 41612 break;
16632
16633 case down: //d
16634 42622 flip=0;
16635 42622 tile+=4;
16636 42622 break;
16637
16638 case left: //l
16639 37916 flip=0;
16640 37916 tile+=8;
16641 37916 break;
16642
16643 case right: //r
16644 38458 flip=0;
16645 38458 tile+=12;
16646 38458 break;
16647
16648 case l_up: //ul
16649 38564 flip=0;
16650 38564 tile+=20;
16651 38564 break;
16652
16653 case r_up: //ur
16654 38568 flip=0;
16655 38568 tile+=24;
16656 38568 break;
16657
16658 case l_down: //dl
16659 38662 flip=0;
16660 38662 tile+=28;
16661 38662 break;
16662
16663 case r_down: //dr
16664 39466 flip=0;
16665 39466 tile+=32;
16666 39466 break;
16667 }
16668
16669 315868 tile += ((clk&6)>>1);
16670 315868 }
16671 else
16672 {
16673 tile += (clk&4)?1:0;
16674 }
16675
16676
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16677 283752 enemy::draw(dest);
16678 315868 }
16679
16680 257368 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16681 {
16682
4/6
✓ Branch 0 taken 150748 times.
✓ Branch 1 taken 106620 times.
✓ Branch 2 taken 150748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150748 times.
✗ Branch 5 not taken.
257368 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16683
4/8
✓ Branch 0 taken 257368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257368 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257368 times.
✗ Branch 7 not taken.
257368 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16684
1/2
✓ Branch 0 taken 257368 times.
✗ Branch 1 not taken.
257368 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16685 257368 }
16686
16687 74291 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16688 {
16689 // Kludge
16690
4/8
✓ Branch 0 taken 74291 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74291 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74291 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74291 times.
✗ Branch 7 not taken.
74291 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16691 74291 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74291 times.
74291 delete w;
16693 74291 return ret;
16694 }
16695
16696 9148 void enemy_scored(int32_t index)
16697 {
16698 9148 ((enemy*)guys.spr(index))->scored=true;
16699 9148 }
16700
16701 2188 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16702 {
16703
5/8
✓ Branch 0 taken 2188 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2188 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1909 times.
✓ Branch 6 taken 2188 times.
✗ Branch 7 not taken.
2188 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16704
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 762 times.
2188 if (isdungeon(g->screen_spawned))
16705 762 g->y += 1;
16706
5/6
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1270 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2188 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16707 {
16708 4 g->o_tile = parentscr->guytile;
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16710 4 g->flags &= ~guy_invisible;
16711 4 g->cs = parentscr->guycs;
16712 4 }
16713 2188 guys.add(g);
16714 2188 }
16715
16716 23701 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16717 {
16718
4/8
✓ Branch 0 taken 23701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23701 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23701 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23701 times.
✗ Branch 7 not taken.
23701 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16719 23701 items.add(i);
16720 23701 }
16721
16722 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16723 {
16724
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16725 150 items.add(i);
16726 150 }
16727
16728 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16729 {
16730
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16731 3 items.add(i);
16732 3 }
16733
16734 19250 void add_item_for_screen(int32_t screen, item* item)
16735 {
16736 19250 item->screen_spawned = screen;
16737 19250 items.add(item);
16738 19250 }
16739
16740 96 void kill_em_all()
16741 {
16742
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16743 {
16744 353 enemy *e = ((enemy*)guys.spr(i));
16745
16746
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16747
16748 323 e->kickbucket();
16749 323 }
16750 96 }
16751
16752 bool can_kill_em_all()
16753 {
16754 for(int32_t i=0; i<guys.Count(); i++)
16755 {
16756 enemy *e = ((enemy*)guys.spr(i));
16757
16758 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16759 if(e->superman) continue;
16760 return true;
16761 }
16762 return false;
16763 }
16764
16765 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16766 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16767 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16768 {
16769 for(int32_t i=0; i<guys.Count(); i++)
16770 {
16771 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16772 {
16773 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16774 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16775 {
16776 return i;
16777 }
16778 }
16779 }
16780
16781 return -1;
16782 }
16783
16784 13092091 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16785 {
16786
4/4
✓ Branch 0 taken 16463 times.
✓ Branch 1 taken 13075628 times.
✓ Branch 2 taken 33677751 times.
✓ Branch 3 taken 13061226 times.
46738977 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16787 {
16788
2/2
✓ Branch 0 taken 30865 times.
✓ Branch 1 taken 33646886 times.
33677751 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16789 {
16790 30865 return i;
16791 }
16792 33646886 }
16793
16794 13061226 return -1;
16795 13092091 }
16796
16797 // For Hero's hit detection. Count them if they are dying.
16798 52230 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16799 {
16800 52230 enemy *e = (enemy*)guys.spr(index);
16801
3/4
✓ Branch 0 taken 52230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27905 times.
✓ Branch 3 taken 24325 times.
52230 if(!e || e->hp > 0)
16802 27905 return -1;
16803
16804 24325 bool d = e->dying;
16805 24325 int32_t hc = e->hclk;
16806 24325 e->dying = false;
16807 24325 e->hclk = 0;
16808 24325 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16809 24325 e->dying = d;
16810 24325 e->hclk = hc;
16811
16812
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24168 times.
24325 return hit ? index : -1;
16813 52230 }
16814
16815 14602825 bool hasMainGuy(int screen)
16816 {
16817
2/2
✓ Branch 0 taken 15887770 times.
✓ Branch 1 taken 5915045 times.
21802815 for(int32_t i=0; i<guys.Count(); i++)
16818 {
16819 15887770 enemy* e = (enemy*)guys.spr(i);
16820
4/4
✓ Branch 0 taken 15423936 times.
✓ Branch 1 taken 463834 times.
✓ Branch 2 taken 8687780 times.
✓ Branch 3 taken 6736156 times.
15887770 if (e->screen_spawned == screen && e->mainguy)
16821 {
16822 8687780 return true;
16823 }
16824 7199990 }
16825
16826 5915045 return false;
16827 14602825 }
16828
16829 138 void EatHero(int32_t index)
16830 {
16831 138 ((eStalfos*)guys.spr(index))->eathero();
16832 138 }
16833
16834 9 void GrabHero(int32_t index)
16835 {
16836 9 ((eWallM*)guys.spr(index))->grabhero();
16837 9 }
16838
16839 1338 bool CarryHero()
16840 {
16841
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16842 {
16843
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
16844 {
16845
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16846 {
16847 1338 Hero.x=guys.spr(i)->x;
16848 1338 Hero.y=guys.spr(i)->y;
16849 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16850 }
16851 505 }
16852
16853 // Like Likes currently can't carry Hero.
16854 /*
16855 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16856 {
16857 if(((eLikeLike*)guys.spr(i))->hashero)
16858 {
16859 Hero.x=guys.spr(i)->x;
16860 Hero.y=guys.spr(i)->y;
16861 return (true);
16862 }
16863 }*/
16864 2595 }
16865
16866 return false;
16867 1338 }
16868
16869 // Move item with guy
16870 void movefairy(zfix &x,zfix &y,int32_t misc)
16871 {
16872 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16873
16874 if(i!=-1)
16875 {
16876 x = guys.spr(i)->x;
16877 y = guys.spr(i)->y;
16878 }
16879 }
16880
16881 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16882 void movefairy2(zfix x,zfix y,int32_t misc)
16883 {
16884 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16885
16886 if(i!=-1)
16887 {
16888 guys.spr(i)->x = x;
16889 guys.spr(i)->y = y;
16890 }
16891 }// Move item with guy
16892
16893 60573 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16894 {
16895 60573 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16896
16897
1/2
✓ Branch 0 taken 60573 times.
✗ Branch 1 not taken.
60573 if(fairy)
16898 {
16899 60573 x = fairy->x;
16900 60573 y = fairy->y;
16901 60573 }
16902 60573 }
16903
16904 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16905 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16906 {
16907 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16908
16909
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16910 {
16911 404 fairy->x = x;
16912 404 fairy->y = y;
16913 404 }
16914 404 }
16915
16916 void killfairy(int32_t misc)
16917 {
16918 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16919 guys.del(i);
16920 }
16921
16922 218 int32_t getGuyIndex(const int32_t eid)
16923 {
16924
1/2
✓ Branch 0 taken 825 times.
✗ Branch 1 not taken.
825 for(word i = 0; i < guys.Count(); i++)
16925 {
16926
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 607 times.
825 if(guys.spr(i)->getUID() == eid)
16927 218 return i;
16928 607 }
16929
16930 return -1;
16931 218 }
16932
16933 218 void killfairynew(item const &itemfairy)
16934 {
16935 218 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16936
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16937 218 }
16938
16939 //Should probably change this to return an 'enemy*', null on failure -Em
16940 21745 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16941 {
16942 21745 return addenemy_z(screen,x,y,0,id,clk);
16943 }
16944
16945 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16946 {
16947 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16948 }
16949
16950 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16951 {
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16953
16954 1997 int32_t ret = 0;
16955 1997 sprite *e=NULL;
16956
16957
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
16958 {
16959 //Fixme: possible enemy memory leak. (minor)
16960 case eeWALK:
16961
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16962 110 break;
16963
16964 case eeLEV:
16965 e = new eLeever((zfix)x,(zfix)y,id,clk);
16966 break;
16967
16968 case eeTEK:
16969 e = new eTektite((zfix)x,(zfix)y,id,clk);
16970 break;
16971
16972 case eePEAHAT:
16973 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16974 break;
16975
16976 case eeZORA:
16977 e = new eZora((zfix)x,(zfix)y,id,clk);
16978 break;
16979
16980 case eeGHINI:
16981 e = new eGhini((zfix)x,(zfix)y,id,clk);
16982 break;
16983
16984 case eeKEESE:
16985
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16986 1865 break;
16987
16988 case eeWIZZ:
16989
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16990 15 break;
16991
16992 case eePROJECTILE:
16993 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16994 break;
16995
16996 case eeWALLM:
16997 e = new eWallM((zfix)x,(zfix)y,id,clk);
16998 break;
16999
17000 case eeAQUA:
17001 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17002 break;
17003
17004 case eeMOLD:
17005 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17006 break;
17007
17008 case eeMANHAN:
17009
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17010 1 break;
17011
17012 case eeGLEEOK:
17013 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17014 break;
17015
17016 case eeGHOMA:
17017 e = new eGohma((zfix)x,(zfix)y,id,clk);
17018 break;
17019
17020 case eeLANM:
17021 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17022 break;
17023
17024 case eeGANON:
17025 e = new eGanon((zfix)x,(zfix)y,id,clk);
17026 break;
17027
17028 case eeFAIRY:
17029 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17030 break;
17031
17032 case eeFIRE:
17033
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17034 2 break;
17035
17036 case eeOTHER:
17037 e = new eOther((zfix)x,(zfix)y,id,clk);
17038 break;
17039
17040
17041 case eeSCRIPT01:
17042 case eeSCRIPT02:
17043 case eeSCRIPT03:
17044 case eeSCRIPT04:
17045 case eeSCRIPT05:
17046 case eeSCRIPT06:
17047 case eeSCRIPT07:
17048 case eeSCRIPT08:
17049 case eeSCRIPT09:
17050 case eeSCRIPT10:
17051 case eeSCRIPT11:
17052 case eeSCRIPT12:
17053 case eeSCRIPT13:
17054 case eeSCRIPT14:
17055 case eeSCRIPT15:
17056 case eeSCRIPT16:
17057 case eeSCRIPT17:
17058 case eeSCRIPT18:
17059 case eeSCRIPT19:
17060 case eeSCRIPT20:
17061 {
17062 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17063 {
17064 e = new eScript((zfix)x,(zfix)y,id,clk);
17065 break;
17066 }
17067 else return 0;
17068 }
17069
17070 case eeFFRIENDLY01:
17071 case eeFFRIENDLY02:
17072 case eeFFRIENDLY03:
17073 case eeFFRIENDLY04:
17074 case eeFFRIENDLY05:
17075 case eeFFRIENDLY06:
17076 case eeFFRIENDLY07:
17077 case eeFFRIENDLY08:
17078 case eeFFRIENDLY09:
17079 case eeFFRIENDLY10:
17080 {
17081 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17082 {
17083 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17084 }
17085 else return 0;
17086
17087 }
17088
17089 case eeSPINTILE:
17090 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17091 break;
17092
17093 // and these enemies use the misc10/misc2 value
17094 case eeROCK:
17095 {
17096 switch(guysbuf[id&0xFFF].attributes[9])
17097 {
17098 case 1:
17099 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17100 break;
17101
17102 case 0:
17103 default:
17104 e = new eRock((zfix)x,(zfix)y,id,clk);
17105 break;
17106 }
17107
17108 break;
17109 }
17110
17111 case eeTRAP:
17112 {
17113 switch(guysbuf[id&0xFFF].attributes[1])
17114 {
17115 case 1:
17116 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17117 break;
17118
17119 case 0:
17120 default:
17121 e = new eTrap((zfix)x,(zfix)y,id,clk);
17122 break;
17123 }
17124
17125 break;
17126 }
17127
17128 case eeDONGO:
17129 {
17130 switch(guysbuf[id&0xFFF].attributes[9])
17131 {
17132 case 1:
17133 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17134 break;
17135
17136 case 0:
17137 default:
17138 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17139 break;
17140 }
17141
17142 break;
17143 }
17144
17145 case eeDIG:
17146 {
17147
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17148 {
17149 case 1:
17150 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17151 break;
17152
17153 4 case 0:
17154 default:
17155
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17156 4 break;
17157 }
17158
17159 4 break;
17160 }
17161
17162 case eePATRA:
17163 {
17164 switch(guysbuf[id&0xFFF].attributes[9])
17165 {
17166 case 1:
17167 if (get_qr(qr_HARDCODED_BS_PATRA))
17168 {
17169 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17170 break;
17171 }
17172 [[fallthrough]];
17173 case 0:
17174 default:
17175 e = new ePatra((zfix)x,(zfix)y,id,clk);
17176 break;
17177 }
17178
17179 break;
17180 }
17181
17182 case eeGUY:
17183 {
17184 switch(guysbuf[id&0xFFF].attributes[9])
17185 {
17186 case 1:
17187 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17188 break;
17189
17190 case 0:
17191 default:
17192 e = new eNPC((zfix)x,(zfix)y,id,clk);
17193 break;
17194 }
17195
17196 break;
17197 }
17198
17199 case eeNONE:
17200 if(guysbuf[id&0xFFF].attributes[9] ==1)
17201 {
17202 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17203 break;
17204 break;
17205 }
17206 [[fallthrough]];
17207 default:
17208
17209 return 0;
17210 }
17211
17212 1997 ret++; // Made one enemy.
17213
17214
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17215 {
17216 7 e->z = (zfix)z;
17217 7 }
17218
17219
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17220 1997 e->setParent(parent);
17221
17222
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17223 {
17224 return 0;
17225 }
17226
17227 // add segments of segmented enemies
17228 1997 int32_t c=0;
17229
17230
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17231 {
17232 case eeMOLD:
17233 {
17234 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17235 id &= 0xFFF;
17236
17237 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17238 {
17239 //christ this is messy -DD
17240 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17241
17242 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17243 {
17244 al_trace("Moldorm segment %d could not be created!\n",i+1);
17245
17246 for(int32_t j=0; j<i+1; j++)
17247 guys.del(guys.Count()-1);
17248
17249 return 0;
17250 }
17251
17252 if(i>0)
17253 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17254
17255 ret++;
17256 }
17257
17258 break;
17259 }
17260
17261 case eeLANM:
17262 {
17263 id &= 0xFFF;
17264 int32_t shft = guysbuf[id].attributes[1];
17265 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17266
17267 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17268 {
17269 al_trace("Lanmola segment 1 could not be created!\n");
17270 guys.del(guys.Count()-1);
17271 return 0;
17272 }
17273
17274 ret++;
17275
17276 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17277 {
17278 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17279 {
17280 al_trace("Lanmola segment %d could not be created!\n",i+1);
17281
17282 for(int32_t j=0; j<i+1; j++)
17283 guys.del(guys.Count()-1);
17284
17285 return 0;
17286 }
17287
17288 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17289 ret++;
17290 }
17291 }
17292 break;
17293
17294 case eeMANHAN:
17295 1 id &= 0xFFF;
17296
17297
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17298 {
17299
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17300 {
17301 al_trace("Manhandla head %d could not be created!\n",i+1);
17302
17303 for(int32_t j=0; j<i+1; j++)
17304 {
17305 guys.del(guys.Count()-1);
17306 }
17307
17308 return 0;
17309 }
17310
17311 4 ret++;
17312 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17313 4 }
17314
17315 1 break;
17316
17317 case eeGLEEOK:
17318 {
17319 id &= 0xFFF;
17320
17321 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17322 {
17323 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17324 {
17325 al_trace("Gleeok head %d could not be created!\n",i+1);
17326
17327 for(int32_t j=0; j<i+1; j++)
17328 {
17329 guys.del(guys.Count()-1);
17330 }
17331
17332 return false;
17333 }
17334
17335 c-=guysbuf[id].attributes[3];
17336 ret++;
17337 }
17338 }
17339 break;
17340
17341
17342 case eePATRA:
17343 {
17344 id &= 0xFFF;
17345 int32_t outeyes = 0;
17346
17347 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17348 {
17349 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17350 {
17351 al_trace("Patra outer eye %d could not be created!\n",i+1);
17352
17353 for(int32_t j=0; j<i+1; j++)
17354 guys.del(guys.Count()-1);
17355
17356 return 0;
17357 }
17358 else
17359 outeyes++;
17360
17361 ret++;
17362 }
17363
17364 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17365 {
17366 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17367 {
17368 al_trace("Patra inner eye %d could not be created!\n",i+1);
17369
17370 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17371 guys.del(guys.Count()-1);
17372
17373 return 0;
17374 }
17375
17376 ret++;
17377 }
17378
17379 break;
17380 }
17381 }
17382
17383
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17384 {
17385 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17386 2001 e->screen_spawned = screen;
17387 2001 }
17388
17389 1997 return ret;
17390 1997 }
17391
17392 // Returns number of enemies/segments created
17393 101672 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17394 {
17395 101672 int32_t realid = id&0xFFF;
17396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101672 times.
101672 if( realid > MAXGUYS )
17397 {
17398 return 0;
17399 }
17400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101672 times.
101672 if(id <= 0) return 0;
17401
17402 101672 int32_t ret = 0;
17403 101672 sprite *e=NULL;
17404
17405
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49933 times.
✓ Branch 4 taken 3912 times.
✓ Branch 5 taken 5209 times.
✓ Branch 6 taken 1813 times.
✓ Branch 7 taken 2792 times.
✓ Branch 8 taken 460 times.
✓ Branch 9 taken 11800 times.
✓ Branch 10 taken 5277 times.
✓ Branch 11 taken 4381 times.
✓ Branch 12 taken 977 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 167 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 731 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7630 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2454 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 291 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 531 times.
101672 switch(guysbuf[id&0xFFF].family)
17406 {
17407 //Fixme: possible enemy memory leak. (minor)
17408 case eeWALK:
17409
3/6
✓ Branch 0 taken 49933 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49933 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49933 times.
✗ Branch 5 not taken.
49933 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17410 49933 break;
17411
17412 case eeLEV:
17413
3/6
✓ Branch 0 taken 3912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3912 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3912 times.
✗ Branch 5 not taken.
3912 e = new eLeever((zfix)x,(zfix)y,id,clk);
17414 3912 break;
17415
17416 case eeTEK:
17417
3/6
✓ Branch 0 taken 5209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5209 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5209 times.
✗ Branch 5 not taken.
5209 e = new eTektite((zfix)x,(zfix)y,id,clk);
17418 5209 break;
17419
17420 case eePEAHAT:
17421
3/6
✓ Branch 0 taken 1813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1813 times.
✗ Branch 5 not taken.
1813 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17422 1813 break;
17423
17424 case eeZORA:
17425
3/6
✓ Branch 0 taken 2792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2792 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2792 times.
✗ Branch 5 not taken.
2792 e = new eZora((zfix)x,(zfix)y,id,clk);
17426 2792 break;
17427
17428 case eeGHINI:
17429
3/6
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✗ Branch 5 not taken.
460 e = new eGhini((zfix)x,(zfix)y,id,clk);
17430 460 break;
17431
17432 case eeKEESE:
17433
3/6
✓ Branch 0 taken 11800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11800 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11800 times.
✗ Branch 5 not taken.
11800 e = new eKeese((zfix)x,(zfix)y,id,clk);
17434 11800 break;
17435
17436 case eeWIZZ:
17437
3/6
✓ Branch 0 taken 5277 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5277 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5277 times.
✗ Branch 5 not taken.
5277 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17438 5277 break;
17439
17440 case eePROJECTILE:
17441
3/6
✓ Branch 0 taken 4381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4381 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4381 times.
✗ Branch 5 not taken.
4381 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17442 4381 break;
17443
17444 case eeWALLM:
17445
3/6
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 977 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 977 times.
✗ Branch 5 not taken.
977 e = new eWallM((zfix)x,(zfix)y,id,clk);
17446 977 break;
17447
17448 case eeAQUA:
17449
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17450 126 break;
17451
17452 case eeMOLD:
17453
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17454 618 break;
17455
17456 case eeMANHAN:
17457
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17458 149 break;
17459
17460 case eeGLEEOK:
17461
7/12
✓ Branch 0 taken 167 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 167 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 167 times.
✓ Branch 6 taken 151 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 151 times.
✓ Branch 10 taken 167 times.
✗ Branch 11 not taken.
167 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17462 167 break;
17463
17464 case eeGHOMA:
17465
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17466 93 break;
17467
17468 case eeLANM:
17469
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17470 420 break;
17471
17472 case eeGANON:
17473
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17474 13 break;
17475
17476 case eeFAIRY:
17477
3/6
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 731 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 731 times.
✗ Branch 5 not taken.
731 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17478 731 break;
17479
17480 case eeFIRE:
17481
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17482 758 break;
17483
17484 case eeOTHER:
17485
3/6
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
7630 e = new eOther((zfix)x,(zfix)y,id,clk);
17486 7630 break;
17487
17488
17489 case eeSCRIPT01:
17490 case eeSCRIPT02:
17491 case eeSCRIPT03:
17492 case eeSCRIPT04:
17493 case eeSCRIPT05:
17494 case eeSCRIPT06:
17495 case eeSCRIPT07:
17496 case eeSCRIPT08:
17497 case eeSCRIPT09:
17498 case eeSCRIPT10:
17499 case eeSCRIPT11:
17500 case eeSCRIPT12:
17501 case eeSCRIPT13:
17502 case eeSCRIPT14:
17503 case eeSCRIPT15:
17504 case eeSCRIPT16:
17505 case eeSCRIPT17:
17506 case eeSCRIPT18:
17507 case eeSCRIPT19:
17508 case eeSCRIPT20:
17509 {
17510 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17511 {
17512 e = new eScript((zfix)x,(zfix)y,id,clk);
17513 break;
17514 }
17515 else return 0;
17516 }
17517
17518 case eeFFRIENDLY01:
17519 case eeFFRIENDLY02:
17520 case eeFFRIENDLY03:
17521 case eeFFRIENDLY04:
17522 case eeFFRIENDLY05:
17523 case eeFFRIENDLY06:
17524 case eeFFRIENDLY07:
17525 case eeFFRIENDLY08:
17526 case eeFFRIENDLY09:
17527 case eeFFRIENDLY10:
17528 {
17529 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17530 {
17531 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17532 }
17533 else return 0;
17534
17535 }
17536
17537 case eeSPINTILE:
17538
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17539 94 break;
17540
17541 // and these enemies use the misc10/misc2 value
17542 case eeROCK:
17543 {
17544
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17545 {
17546 case 1:
17547
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17548 30 break;
17549
17550 354 case 0:
17551 default:
17552
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17553 354 break;
17554 }
17555
17556 384 break;
17557 }
17558
17559 case eeTRAP:
17560 {
17561
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
✓ Branch 2 taken 1623 times.
2454 switch(guysbuf[id&0xFFF].attributes[1])
17562 {
17563 case 1:
17564
3/6
✓ Branch 0 taken 831 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 831 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 831 times.
✗ Branch 5 not taken.
831 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17565 831 break;
17566
17567 1623 case 0:
17568 default:
17569
3/6
✓ Branch 0 taken 1623 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1623 times.
✗ Branch 5 not taken.
1623 e = new eTrap((zfix)x,(zfix)y,id,clk);
17570 1623 break;
17571 }
17572
17573 2454 break;
17574 }
17575
17576 case eeDONGO:
17577 {
17578
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17579 {
17580 case 1:
17581
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17582 48 break;
17583
17584 203 case 0:
17585 default:
17586
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17587 203 break;
17588 }
17589
17590 251 break;
17591 }
17592
17593 case eeDIG:
17594 {
17595
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17596 {
17597 case 1:
17598
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17599 327 break;
17600
17601 76 case 0:
17602 default:
17603
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17604 76 break;
17605 }
17606
17607 403 break;
17608 }
17609
17610 case eePATRA:
17611 {
17612
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 102 times.
291 switch(guysbuf[id&0xFFF].attributes[9])
17613 {
17614 case 1:
17615
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17616 {
17617
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17618 102 break;
17619 }
17620 [[fallthrough]];
17621 189 case 0:
17622 default:
17623
3/6
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 189 times.
✗ Branch 5 not taken.
189 e = new ePatra((zfix)x,(zfix)y,id,clk);
17624 189 break;
17625 }
17626
17627 291 break;
17628 }
17629
17630 case eeGUY:
17631 {
17632
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17633 {
17634 case 1:
17635 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17636 break;
17637
17638 5 case 0:
17639 default:
17640
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17641 5 break;
17642 }
17643
17644 5 break;
17645 }
17646
17647 case eeNONE:
17648
1/2
✓ Branch 0 taken 531 times.
✗ Branch 1 not taken.
531 if(guysbuf[id&0xFFF].attributes[9] ==1)
17649 {
17650
3/6
✓ Branch 0 taken 531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 531 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 531 times.
✗ Branch 5 not taken.
531 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17651 531 break;
17652 }
17653 [[fallthrough]];
17654 default:
17655
17656 return 0;
17657 }
17658
17659 101672 ret++; // Made one enemy.
17660
17661
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101495 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
101672 if(z && canfall(id))
17662 {
17663 152 e->z = (zfix)z;
17664 152 }
17665
17666
2/2
✓ Branch 0 taken 101495 times.
✓ Branch 1 taken 177 times.
101672 ((enemy*)e)->ceiling = (z && canfall(id));
17667
17668
1/2
✓ Branch 0 taken 101672 times.
✗ Branch 1 not taken.
101672 if(!guys.add(e))
17669 {
17670 return 0;
17671 }
17672
17673 // add segments of segmented enemies
17674 101672 int32_t c=0;
17675
17676
6/6
✓ Branch 0 taken 100027 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 167 times.
✓ Branch 5 taken 291 times.
101672 switch(guysbuf[id&0xFFF].family)
17677 {
17678 case eeMOLD:
17679 {
17680 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17681 618 id &= 0xFFF;
17682
17683
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17684 {
17685 //christ this is messy -DD
17686 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17687
17688
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17689 {
17690 al_trace("Moldorm segment %d could not be created!\n",i+1);
17691
17692 for(int32_t j=0; j<i+1; j++)
17693 guys.del(guys.Count()-1);
17694
17695 return 0;
17696 }
17697
17698
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17699 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17700
17701 3150 ret++;
17702 3150 }
17703
17704 618 break;
17705 }
17706
17707 case eeLANM:
17708 {
17709 420 id &= 0xFFF;
17710 420 int32_t shft = guysbuf[id].attributes[1];
17711 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17712
17713
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17714 {
17715 al_trace("Lanmola segment 1 could not be created!\n");
17716 guys.del(guys.Count()-1);
17717 return 0;
17718 }
17719
17720 420 ret++;
17721
17722
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17723 {
17724
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17725 {
17726 al_trace("Lanmola segment %d could not be created!\n",i+1);
17727
17728 for(int32_t j=0; j<i+1; j++)
17729 guys.del(guys.Count()-1);
17730
17731 return 0;
17732 }
17733
17734 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17735 1847 ret++;
17736 1847 }
17737 }
17738 420 break;
17739
17740 case eeMANHAN:
17741 149 id &= 0xFFF;
17742
17743
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17744 {
17745
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17746 {
17747 al_trace("Manhandla head %d could not be created!\n",i+1);
17748
17749 for(int32_t j=0; j<i+1; j++)
17750 {
17751 guys.del(guys.Count()-1);
17752 }
17753
17754 return 0;
17755 }
17756
17757 688 ret++;
17758 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17759 688 }
17760
17761 149 break;
17762
17763 case eeGLEEOK:
17764 {
17765 167 id &= 0xFFF;
17766 167 eGleeok* parent = (eGleeok*)e;
17767
17768
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 664 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 664 times.
✓ Branch 6 taken 529 times.
✓ Branch 7 taken 167 times.
696 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17769 {
17770
3/6
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 529 times.
✗ Branch 5 not taken.
529 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17771
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!guys.add(head))
17772 {
17773 al_trace("Gleeok head %d could not be created!\n",i+1);
17774
17775 for(int32_t j=0; j<i+1; j++)
17776 {
17777 guys.del(guys.Count()-1);
17778 }
17779
17780 return false;
17781 }
17782
17783 529 head->necktile=parent->necktile;
17784 529 head->dummy_int[1]=parent->necktile;
17785
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 112 times.
529 if(get_qr(qr_NEWENEMYTILES))
17786 {
17787 417 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17788 417 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17789 417 }
17790 else
17791 {
17792 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17793 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17794 }
17795 529 head->tile = head->dummy_int[2];
17796
17797 529 c-=guysbuf[id].attributes[3];
17798 529 ret++;
17799 529 }
17800 }
17801 167 break;
17802
17803
17804 case eePATRA:
17805 {
17806 291 id &= 0xFFF;
17807 291 int32_t outeyes = 0;
17808
17809
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2239 times.
✓ Branch 2 taken 1948 times.
✓ Branch 3 taken 291 times.
2239 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17810 {
17811
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1336 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1336 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1336 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1336 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1948 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17812 {
17813 al_trace("Patra outer eye %d could not be created!\n",i+1);
17814
17815 for(int32_t j=0; j<i+1; j++)
17816 guys.del(guys.Count()-1);
17817
17818 return 0;
17819 }
17820 else
17821 1948 outeyes++;
17822
17823 1948 ret++;
17824 1948 }
17825
17826
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 595 times.
✓ Branch 2 taken 304 times.
✓ Branch 3 taken 291 times.
595 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17827 {
17828
4/8
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 304 times.
✗ Branch 7 not taken.
304 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17829 {
17830 al_trace("Patra inner eye %d could not be created!\n",i+1);
17831
17832 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17833 guys.del(guys.Count()-1);
17834
17835 return 0;
17836 }
17837
17838 304 ret++;
17839 304 }
17840
17841 291 break;
17842 }
17843 }
17844
17845
2/2
✓ Branch 0 taken 110558 times.
✓ Branch 1 taken 101672 times.
212230 for (int i = 0; i < ret; i++)
17846 {
17847 110558 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17848 110558 e->screen_spawned = screen;
17849 110558 }
17850
17851 101672 return ret;
17852 101672 }
17853
17854 2059282 bool isjumper(int32_t id)
17855 {
17856
2/4
✓ Branch 0 taken 2059282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2059282 times.
2059282 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17857 {
17858 return false;
17859 }
17860
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1953404 times.
✓ Branch 2 taken 105869 times.
2059282 switch(guysbuf[id&0xFFF].family)
17861 {
17862 case eeROCK:
17863 case eeTEK:
17864 9 return true;
17865
17866 case eeWALK:
17867
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17868 93604 }
17869
17870 2047008 return false;
17871 2059282 }
17872
17873
17874 7972 bool isfixedtogrid(int32_t id)
17875 {
17876
2/4
✓ Branch 0 taken 7972 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7972 times.
7972 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17877 {
17878 return false;
17879 }
17880
1/2
✓ Branch 0 taken 7972 times.
✗ Branch 1 not taken.
7972 switch(guysbuf[id&0xFFF].family)
17881 {
17882 case eeWALK:
17883 case eeLEV:
17884 case eeZORA:
17885 case eeDONGO:
17886 case eeGANON:
17887 case eeROCK:
17888 case eeGLEEOK:
17889 case eeAQUA:
17890 case eeLANM:
17891 return true;
17892 }
17893
17894 7972 return false;
17895 7972 }
17896
17897 // Can't fall, can have Z value.
17898 52178360 bool isflier(int32_t id)
17899 {
17900
3/4
✓ Branch 0 taken 52178360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 52067502 times.
52178360 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17901 {
17902 110858 return false;
17903 }
17904
2/2
✓ Branch 0 taken 6477276 times.
✓ Branch 1 taken 45590226 times.
52067502 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
17905 {
17906 case eePEAHAT:
17907 case eeKEESE:
17908 case eePATRA:
17909 case eeFAIRY:
17910 case eeGHINI:
17911
17912 // Could theoretically have their Z set by a script
17913 case eeFIRE:
17914 6477276 return true;
17915 break;
17916 }
17917
17918 45590226 return false;
17919 52178360 }
17920
17921 // Can't have Z position
17922 4046103 bool never_in_air(int32_t id)
17923 {
17924
2/4
✓ Branch 0 taken 4046103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4046103 times.
4046103 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17925 {
17926 return false;
17927 }
17928
2/2
✓ Branch 0 taken 4036553 times.
✓ Branch 1 taken 9550 times.
4046103 switch(guysbuf[id&0xFFF].family)
17929 {
17930 case eeMANHAN:
17931 case eeMOLD:
17932 case eeLANM:
17933 case eeGLEEOK:
17934 case eeZORA:
17935 case eeLEV:
17936 case eeAQUA:
17937 case eeROCK:
17938 case eeGANON:
17939 case eeTRAP:
17940 case eePROJECTILE:
17941 case eeSPINTILE:
17942 9550 return true;
17943 }
17944
17945 4036553 return false;
17946 4046103 }
17947
17948 2248208 bool canfall(int32_t id)
17949 {
17950
3/4
✓ Branch 0 taken 2248208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2248162 times.
2248208 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17951 {
17952 46 return false;
17953 }
17954
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2248122 times.
✓ Branch 2 taken 40 times.
2248162 switch(guysbuf[id&0xFFF].family)
17955 {
17956 case eeGUY:
17957 {
17958
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17959 40 return false;
17960
17961 switch(guysbuf[id&0xFFF].attributes[9])
17962 {
17963 case 1:
17964 case 2:
17965 return true;
17966
17967 case 0:
17968 case 3:
17969 default:
17970 return false;
17971 }
17972
17973 case eeGHOMA:
17974 case eeDIG:
17975 return false;
17976 }
17977 }
17978
17979
17980
4/4
✓ Branch 0 taken 2239686 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2059282 times.
2248122 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17981 2248208 }
17982
17983 73437510 bool enemy::enemycanfall(int32_t id, bool checkgrav)
17984 {
17985
3/4
✓ Branch 0 taken 73437510 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 73347912 times.
73437510 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17986 {
17987 89598 return false;
17988 }
17989 //Z_scripterrlog("canfall family is %d:\n", family);
17990 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17991 //if ( family == eeFIRE && id >= eSTART )
17992 //{
17993 // Z_scripterrlog("eeFire\n");
17994 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17995 //}
17996
17997 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17998
17999
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 70843311 times.
✓ Branch 2 taken 2075666 times.
73347912 switch(guysbuf[id&0xFFF].family)
18000 {
18001 case eeGUY:
18002 {
18003
1/2
✓ Branch 0 taken 2075666 times.
✗ Branch 1 not taken.
2075666 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18004 2075666 return false;
18005
18006 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18007 {
18008 case 1:
18009 case 2:
18010 return true;
18011
18012 case 0:
18013 case 3:
18014 default:
18015 return false;
18016 }
18017
18018 case eeGHOMA:
18019 case eeDIG:
18020 428935 return false;
18021 }
18022 }
18023
18024
2/2
✓ Branch 0 taken 38929779 times.
✓ Branch 1 taken 31913532 times.
70843311 if(!checkgrav) return true;
18025 38929779 return (moveflags & move_obeys_grav);
18026
18027 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18028 // {
18029 // if ( moveflags & move_obeys_grav ) return true;
18030 // else return false;
18031 // }
18032 // else
18033 // {
18034 // return (moveflags & move_obeys_grav);
18035 // }
18036 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18037 73437510 }
18038
18039 1265 void addfires()
18040 {
18041
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 457 times.
1265 if(!get_qr(qr_NOGUYFIRES))
18042 {
18043 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18044 457 int32_t bs = get_qr(qr_BSZELDA);
18045 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18046 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18047 457 }
18048 1265 }
18049
18050 // This function runs one time for every screen on the first frame of a region being loaded.
18051 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18052 36834 static void loadguys(mapscr* scr)
18053 {
18054 36834 int screen = scr->screen;
18055 36834 byte Guy=0;
18056 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18057 // Else use mITEM and ipONETIME
18058 36834 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18059 36834 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18060
18061 36834 mapscr* guyscr = scr;
18062
4/4
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 35929 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 431 times.
36834 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18063 {
18064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18065 {
18066 431 Guy=special_warp_return_scr->guy;
18067 431 guyscr = special_warp_return_scr;
18068 431 }
18069 431 }
18070 else
18071 {
18072 36403 Guy=scr->guy;
18073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36403 times.
36403 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18074 36403 mark_visited(screen);
18075 }
18076
18077 113412 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18078
18079 36834 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18080 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18081
4/4
✓ Branch 0 taken 3859 times.
✓ Branch 1 taken 32975 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1309 times.
36834 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18082 {
18083
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1298 times.
1309 if(scr->room==rZELDA)
18084 {
18085 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18086 11 guys.spr(0)->hxofs=1000;
18087 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18088 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18089 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18090 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18091 11 return;
18092 }
18093
18094
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 4 times.
2592 bool ffire = oldguy
18095
2/2
✓ Branch 0 taken 1265 times.
✓ Branch 1 taken 29 times.
1294 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18096 4 : (guyscr->roomflags&RFL_GUYFIRES);
18097
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1265 times.
1298 if(ffire)
18098 1265 addfires();
18099
18100
2/2
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 425 times.
1298 if(screen>=128)
18101
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18102 13 Guy=0;
18103
18104
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1088 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 42 times.
1298 switch(scr->room)
18105 {
18106 case rSP_ITEM:
18107 case rGRUMBLE:
18108 case rBOMBS:
18109 case rARROWS:
18110 case rSWINDLE:
18111 case rMUPGRADE:
18112 case rLEARNSLASH:
18113 case rTAKEONE:
18114
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18115 55 Guy=0;
18116
18117 167 break;
18118
18119 case rREPAIR:
18120 if (get_qr(qr_OLD_DOORREPAIR)) break;
18121 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18122 Guy=0;
18123
18124 break;
18125 case rRP_HC:
18126 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18127 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18128 Guy=0;
18129
18130 break;
18131 case rMONEY:
18132
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18133 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18134 Guy=0;
18135
18136 break;
18137
18138 case rTRIFORCE:
18139 {
18140 42 int32_t tc = TriforceCount();
18141
18142
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 31 times.
42 if(get_qr(qr_4TRI))
18143 {
18144
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18145 10 Guy=0;
18146 9 }
18147 else
18148 {
18149
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 1 times.
31 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18150 30 Guy=0;
18151 }
18152 }
18153 40 break;
18154 }
18155
18156
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1192 times.
1296 if(Guy)
18157 {
18158
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1159 times.
1192 if(ffire)
18159 1159 blockpath=true;
18160
18161
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 780 times.
1192 if(screen<128)
18162 780 sfx(WAV_SCALE);
18163
18164
6/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 725 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 725 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 357 times.
2384 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18165 1192 Hero.Freeze();
18166 1192 }
18167 1296 }
18168
5/6
✓ Branch 0 taken 33716 times.
✓ Branch 1 taken 1809 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33645 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1809 times.
35525 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18169 {
18170 71 sfx(WAV_SCALE);
18171 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18172 71 }
18173
18174 110463 loaditem(scr, dx, dy);
18175
18176 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18177 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18178
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36802 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
36821 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18179 {
18180
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18181 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18182 15 }
18183 36832 }
18184
18185 35590 void loadguys()
18186 {
18187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35590 times.
35590 if (loaded_guys)
18188 return;
18189
18190 35590 loaded_guys = true;
18191 35590 repaircharge = 0;
18192 35590 adjustmagic = false;
18193 35590 learnslash = false;
18194
2/2
✓ Branch 0 taken 106770 times.
✓ Branch 1 taken 35590 times.
142360 for (int32_t i=0; i<3; i++)
18195 {
18196 106770 prices[i] = 0;
18197 106770 }
18198
18199 72424 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18200 36834 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18201 36834 loadguys(scr);
18202 36834 });
18203 35590 }
18204
18205 36840 void loaditem(mapscr* scr, int offx, int offy)
18206 {
18207 36840 int screen = scr->screen;
18208 36840 byte Item = 0;
18209
18210
2/2
✓ Branch 0 taken 35935 times.
✓ Branch 1 taken 905 times.
36840 if(screen<128)
18211 {
18212 35935 Item=scr->item;
18213
18214
4/4
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 34349 times.
✓ Branch 2 taken 32724 times.
✓ Branch 3 taken 3211 times.
35935 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18215 {
18216
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3152 times.
3211 if(scr->flags8&fSECRETITEM)
18217 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18218
2/2
✓ Branch 0 taken 1163 times.
✓ Branch 1 taken 1989 times.
3152 else if(scr->flags&fITEM)
18219 1163 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18220
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 1880 times.
1989 else if(scr->flags11&efCARRYITEM)
18221 109 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18222 else
18223 {
18224 1880 int x = scr->itemx;
18225
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1865 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1880 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18226 -170 :
18227 1880 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18228
3/6
✓ Branch 0 taken 1880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1880 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1880 times.
✗ Branch 5 not taken.
3760 add_item_for_screen(screen, new item(offx + x, offy + y,
18229
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1865 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1865 times.
✗ Branch 9 not taken.
1880 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18230
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1776 times.
1880 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18231 1880 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18232 }
18233 3211 }
18234 35935 }
18235
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 474 times.
905 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18236 {
18237
4/6
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 468 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
490 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18238
4/4
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 146 times.
474 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18239 {
18240 162 Item = special_warp_return_scr->catchall;
18241
18242
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 161 times.
162 if(Item)
18243 {
18244 161 int x = scr->itemx;
18245
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18246 -170 :
18247 161 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18248
3/6
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 161 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
322 add_item_for_screen(screen, new item(offx + x, offy + y,
18249
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 161 times.
✗ Branch 9 not taken.
161 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18250 161 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18251 161 }
18252 162 }
18253 474 }
18254 36840 }
18255
18256 954 void never_return(int32_t screen, int32_t index)
18257 {
18258
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 191 times.
954 if(!get_qr(qr_KILLALL))
18259 191 goto doit;
18260
18261
2/2
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 327 times.
2615 for(int32_t i=0; i<guys.Count(); i++)
18262
4/4
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 540 times.
✓ Branch 3 taken 436 times.
2288 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18263 {
18264 436 goto dontdoit;
18265 327 }
18266
18267 doit:
18268 518 setmapflag(get_scr(screen), mNEVERRET);
18269 dontdoit:
18270 954 return;
18271 }
18272
18273 63683 bool slowguy(int32_t id)
18274 {
18275
2/4
✓ Branch 0 taken 63683 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63683 times.
63683 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18276 {
18277 return false;
18278 }
18279
18280 63683 id = id&0xFFF;
18281
18282
2/2
✓ Branch 0 taken 54068 times.
✓ Branch 1 taken 9615 times.
63683 switch(id)
18283 {
18284 case eOCTO1S:
18285 case eOCTO2S:
18286 case eOCTO1F:
18287 case eOCTO2F:
18288 case eLEV1:
18289 case eLEV2:
18290 case eROCK:
18291 case eBOULDER:
18292 9615 return true;
18293 }
18294
18295 54068 return false;
18296 63683 }
18297
18298 82971 static bool ok2add(mapscr* scr, int32_t id)
18299 {
18300
2/4
✓ Branch 0 taken 82971 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82971 times.
82971 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18301 {
18302 return false;
18303 }
18304
18305 82971 id = id&0xFFF;
18306
18307
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 82142 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
82971 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18308 464 return false;
18309
18310
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 81866 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82507 switch(guysbuf[id].family)
18311 {
18312 // I added a special case for shooters because having traps on the same screen
18313 // was preventing them from spawning due to TMPNORET. This means they will
18314 // never stay dead, though, so it may not be the best solution. - Saf
18315 case eePROJECTILE:
18316 376 return true;
18317
18318
18319 case eeDIG:
18320 {
18321
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18322 {
18323 case 1:
18324
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18325 79 return !getmapflag(scr, mTMPNORET);
18326
18327 47 return true;
18328
18329 75 case 0:
18330 default:
18331 75 return true;
18332 }
18333 }
18334 case eeGANON:
18335 case eeTRAP:
18336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18337
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18338 [[fallthrough]];
18339 default:
18340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81866 times.
81866 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18341 81866 break;
18342 }
18343
18344
2/2
✓ Branch 0 taken 20978 times.
✓ Branch 1 taken 60888 times.
81866 if(!get_qr(qr_NOTMPNORET))
18345 60888 return !getmapflag(scr, mTMPNORET);
18346
18347 20978 return true;
18348 82971 }
18349
18350 1628606 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18351 {
18352
3/4
✓ Branch 0 taken 284756 times.
✓ Branch 1 taken 1343850 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284756 times.
1628606 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18353 {
18354 1343850 return;
18355 }
18356
18357 284756 int32_t ctype = rpos_handle.ctype();
18358
6/6
✓ Branch 0 taken 283248 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 281933 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1165 times.
✓ Branch 5 taken 280768 times.
284756 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18359
18360 11964 auto [x, y] = rpos_handle.xy();
18361
18362 3988 int32_t cx=-1000, cy=-1000;
18363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3988 times.
3988 if(!isfixedtogrid(statueID))
18364 {
18365
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2480 times.
3988 if(ctype==cL_STATUE)
18366 {
18367 1508 cx=x+4;
18368 1508 cy=y+7;
18369 1508 }
18370
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1165 times.
2480 else if(ctype==cR_STATUE)
18371 {
18372 1315 cx=x-8;
18373 1315 cy=y-1;
18374 1315 }
18375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1165 times.
1165 else if(ctype==cC_STATUE)
18376 {
18377 1165 cx=x;
18378 1165 cy=y;
18379 1165 }
18380 3988 }
18381 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18382 {
18383 cx=x;
18384 cy=y;
18385 }
18386
18387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3988 times.
3988 if(cx!=-1000) // No point creating it if this is false
18388 {
18389
2/2
✓ Branch 0 taken 9705 times.
✓ Branch 1 taken 3984 times.
13689 for(int32_t j=0; j<guys.Count(); j++)
18390 {
18391
4/4
✓ Branch 0 taken 1694 times.
✓ Branch 1 taken 8011 times.
✓ Branch 2 taken 1690 times.
✓ Branch 3 taken 4 times.
9705 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18392 {
18393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18394 4 return; // No point deleting it. A script might be toying with it in some way.
18395 else
18396 guys.del(j);
18397 }
18398 9701 }
18399
18400 3984 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18401 3984 }
18402 1628606 }
18403
18404 34176 static void activate_fireball_statues(mapscr* scr)
18405 {
18406
2/2
✓ Branch 0 taken 32780 times.
✓ Branch 1 taken 1396 times.
34176 if (!(scr->flags11&efFIREBALLS))
18407 {
18408 32780 return;
18409 }
18410
18411 247092 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18412 245696 activate_fireball_statue(rpos_handle);
18413 245696 });
18414 34176 }
18415
18416 34859 void load_default_enemies(mapscr* scr)
18417 {
18418 34859 int screen = scr->screen;
18419 40314 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18420
18421 34859 wallm_load_clk=frame-80;
18422
18423
2/2
✓ Branch 0 taken 32968 times.
✓ Branch 1 taken 1891 times.
34859 if(scr->flags11&efZORA)
18424 {
18425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1891 times.
1891 if(zoraID>=0)
18426 5673 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18427 1891 }
18428
18429
2/2
✓ Branch 0 taken 34681 times.
✓ Branch 1 taken 178 times.
34859 if(scr->flags11&efTRAP4)
18430 {
18431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18432 {
18433 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18434 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18435 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18436 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18437 178 }
18438 178 }
18439
18440 6170043 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18441 6135184 int32_t ctype = rpos_handle.ctype();
18442 6135184 int32_t cflag = rpos_handle.sflag();
18443 6135184 int32_t cflag_i = rpos_handle.cflag();
18444
18445
4/6
✓ Branch 0 taken 6135184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6134845 times.
✓ Branch 3 taken 339 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6134845 times.
6135184 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18446 {
18447 339 auto [x, y] = rpos_handle.xy();
18448
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 329 times.
339 if(trapLOSHorizontalID>=0)
18449 987 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18450 339 }
18451
4/6
✓ Branch 0 taken 6134845 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6134649 times.
✓ Branch 3 taken 196 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6134649 times.
6134845 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18452 {
18453 196 auto [x, y] = rpos_handle.xy();
18454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 if(trapLOSVerticalID>=0)
18455 588 addenemy(screen, x, y, trapLOSVerticalID, -14);
18456 196 }
18457
4/6
✓ Branch 0 taken 6134649 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6134371 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6134371 times.
6134649 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18458 {
18459 278 auto [x, y] = rpos_handle.xy();
18460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18461 {
18462
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18463 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18464 278 }
18465 278 }
18466
4/6
✓ Branch 0 taken 6134371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6133973 times.
✓ Branch 3 taken 398 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6133973 times.
6134371 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18467 {
18468 398 auto [x, y] = rpos_handle.xy();
18469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(trapConstantHorizontalID>=0)
18470 1194 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18471 398 }
18472
4/6
✓ Branch 0 taken 6133973 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6133540 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6133540 times.
6133973 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18473 {
18474 433 auto [x, y] = rpos_handle.xy();
18475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18476 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18477 433 }
18478
18479
1/2
✓ Branch 0 taken 6135184 times.
✗ Branch 1 not taken.
6135184 if(ctype==cSPINTILE1)
18480 {
18481 awaken_spinning_tile(rpos_handle);
18482 }
18483 6135184 });
18484
18485
2/2
✓ Branch 0 taken 34803 times.
✓ Branch 1 taken 56 times.
34859 if(scr->flags11&efTRAP2)
18486 {
18487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18488 {
18489
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18490 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18491
18492
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18493 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18494 56 }
18495 56 }
18496
18497
2/2
✓ Branch 0 taken 34776 times.
✓ Branch 1 taken 83 times.
34859 if(scr->flags11&efROCKS)
18498 {
18499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18500 {
18501 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18502 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18503 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18504 83 }
18505 83 }
18506 34859 }
18507
18508 #define SLOPE_STAGE_COMBOS 0
18509 #define SLOPE_STAGE_FFCS 1
18510 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18511
18512 20801989 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18513 {
18514
2/2
✓ Branch 0 taken 4645463 times.
✓ Branch 1 taken 16156526 times.
20801989 if (stage == SLOPE_STAGE_COMBOS)
18515 16156526 return (region_num_rpos*arg1)+arg2;
18516
2/2
✓ Branch 0 taken 4500554 times.
✓ Branch 1 taken 144909 times.
4645463 if (stage == SLOPE_STAGE_FFCS)
18517 4500554 return (region_num_rpos*7)+arg1;
18518
1/2
✓ Branch 0 taken 144909 times.
✗ Branch 1 not taken.
144909 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18519 144909 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18520 // TODO: what about FFCs from bordering screens?
18521
18522 assert(false);
18523 return 0;
18524 20801989 }
18525
18526 16156526 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18527 {
18528 16156526 mapscr* s = rpos_handle.scr;
18529 16156526 auto& cmb = rpos_handle.combo();
18530
18531 16156526 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18532 16156526 auto it = slopes.find(id);
18533
18534 16156526 bool wasSlope = it!=slopes.end();
18535 16156526 bool isSlope = cmb.type == cSLOPE;
18536
18537
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16156390 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16156526 if(isSlope && !wasSlope)
18538 {
18539 272 auto [x, y] = rpos_handle.xy();
18540 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18541 136 }
18542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16156390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16156390 else if(wasSlope && !isSlope)
18543 {
18544 slopes.erase(it);
18545 }
18546 16156526 }
18547
18548 144909 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18549 {
18550 144909 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18551 144909 auto it = slopes.find(id);
18552
18553 144909 bool wasSlope = it!=slopes.end();
18554 144909 bool isSlope = is_slope;
18555
18556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144909 if(isSlope && !wasSlope)
18557 {
18558 static std::vector<word> TMP;
18559 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18560 TMP.resize(num_border_combos * 7 * 4);
18561
18562 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18563 TMP[tmp_index] = cid;
18564 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18565 }
18566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144909 else if(wasSlope && !isSlope)
18567 {
18568 slopes.erase(it);
18569 }
18570 144909 }
18571
18572 // Load a single column or row from a nearby screen, and load its slopes.
18573 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18574 {
18575 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18576
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18577 171 return;
18578
18579 3713 int offx = 0;
18580 3713 int offy = 0;
18581
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18582 913 offy = -16;
18583
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18584 862 offy = world_h;
18585
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18586 968 offx = -16;
18587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18588 970 offx = world_w;
18589
18590
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18591 {
18592 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18593
2/2
✓ Branch 0 taken 10824 times.
✓ Branch 1 taken 15167 times.
25991 if (!scr) continue;
18594
18595 10824 int slope_count = layer * (16*2);
18596
18597
4/4
✓ Branch 0 taken 7999 times.
✓ Branch 1 taken 2825 times.
✓ Branch 2 taken 2830 times.
✓ Branch 3 taken 5169 times.
10824 if (dir == left || dir == right)
18598 {
18599 5655 int x = dir == left ? 15 : 0;
18600
2/2
✓ Branch 0 taken 62205 times.
✓ Branch 1 taken 5655 times.
67860 for (int y = 0; y < 11; y++)
18601 {
18602 62205 int pos = y * 16 + x;
18603 62205 int cid = scr->data[pos];
18604 62205 bool is_slope = combobuf[cid].type == cSLOPE;
18605
1/2
✓ Branch 0 taken 62205 times.
✗ Branch 1 not taken.
62205 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18606 62205 }
18607 5655 }
18608
3/4
✓ Branch 0 taken 2494 times.
✓ Branch 1 taken 2675 times.
✓ Branch 2 taken 2494 times.
✗ Branch 3 not taken.
5169 else if (dir == up || dir == down)
18609 {
18610 5169 int y = dir == up ? 10 : 0;
18611
2/2
✓ Branch 0 taken 82704 times.
✓ Branch 1 taken 5169 times.
87873 for (int x = 0; x < 16; x++)
18612 {
18613 82704 int pos = y * 16 + x;
18614 82704 int cid = scr->data[pos];
18615 82704 bool is_slope = combobuf[cid].type == cSLOPE;
18616
1/2
✓ Branch 0 taken 82704 times.
✗ Branch 1 not taken.
82704 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18617 82704 }
18618 5169 }
18619
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15167 times.
✓ Branch 2 taken 10824 times.
25991 }
18620 3884 }
18621
18622 35668 void update_slope_comboposes()
18623 {
18624 14809284 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18625 14773616 update_slope_combopos(rpos_handle);
18626 14773616 });
18627
18628
2/2
✓ Branch 0 taken 34697 times.
✓ Branch 1 taken 971 times.
35668 if (Hero.sideview_mode())
18629 {
18630 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18631
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18632 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18633 971 });
18634 971 }
18635
18636 35668 update_slopes();
18637 35668 }
18638
18639 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18640 1382910 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18641 {
18642 1382910 delete_fireball_shooter(rpos_handle);
18643 1382910 }
18644
18645 //Placeholder in case we need it.
18646 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18647 {
18648 return;
18649 }
18650
18651 // Everything that must be done after we change a screen's combo to another combo. -L
18652 1382910 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18653 {
18654 1382910 rpos_handle.scr->valid |= mVALID;
18655 1382910 activate_fireball_statue(rpos_handle);
18656
18657
2/2
✓ Branch 0 taken 1382816 times.
✓ Branch 1 taken 94 times.
1382910 if(rpos_handle.ctype()==cSPINTILE1)
18658 {
18659 94 awaken_spinning_tile(rpos_handle);
18660 94 }
18661
18662 1382910 update_slope_combopos(rpos_handle);
18663 1382910 }
18664
18665 4500554 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18666 {
18667 4500554 ffcdata* ff = ffc_handle.ffc;
18668 4500554 auto& cmb = ffc_handle.combo();
18669
18670 4500554 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18671 4500554 auto it = slopes.find(id);
18672
18673 4500554 bool wasSlope = it!=slopes.end();
18674
1/2
✓ Branch 0 taken 4500554 times.
✗ Branch 1 not taken.
4500554 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 if(isSlope && !wasSlope)
18676 {
18677 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18678 }
18679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 else if(wasSlope && !isSlope)
18680 {
18681 slopes.erase(it);
18682 }
18683
18684 4500554 ffc_handle.scr->ffcCountMarkDirty();
18685 4500554 }
18686
18687 4414 void screen_combo_modify_pre(int32_t cid)
18688 {
18689 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18690
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18691 {
18692 5195 screen_combo_modify_preroutine(rpos_handle);
18693 5195 }
18694 2808608 });
18695 4414 }
18696 4414 void screen_combo_modify_post(int32_t cid)
18697 {
18698 4414 combo_caches::refresh(cid);
18699
18700 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18701
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18702 {
18703 5195 screen_combo_modify_postroutine(rpos_handle);
18704 5195 }
18705 2808608 });
18706
18707 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18708
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18709 {
18710 58 screen_ffc_modify_postroutine(ffc_handle);
18711 58 }
18712 139772 });
18713 4414 }
18714
18715 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18716 {
18717 94 int cid = rpos_handle.data();
18718 94 int cset = rpos_handle.cset();
18719 282 auto [x, y] = rpos_handle.xy();
18720
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18721 94 }
18722
18723 // It stands for next_side_pos
18724 // moves sle_x and sle_y to the next position
18725 11464 void nsp(bool random)
18726 {
18727
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18728 {
18729
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18730 {
18731 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18732 1634 sle_y = (zc_oldrand()%10)*16;
18733 1634 }
18734 else
18735 {
18736 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18737 1627 sle_x = (zc_oldrand()%15)*16;
18738 }
18739
18740 3261 return;
18741 }
18742
18743
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18744 {
18745
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18746 1855 sle_y+=16;
18747 else
18748 180 sle_x+=16;
18749 2035 }
18750
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18751 {
18752
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18753 2430 sle_x+=16;
18754 else
18755 166 sle_y-=16;
18756 2596 }
18757
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18758 {
18759
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18760 1404 sle_y-=16;
18761 else
18762 148 sle_x-=16;
18763 1552 }
18764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18765 {
18766
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18767 2020 sle_x-=16;
18768 else
18769 sle_y+=16;
18770 2020 }
18771 11464 }
18772
18773 // moves sle_x and sle_y to the next available position
18774 // returns the direction the enemy should face
18775 2429 int32_t next_side_pos(int32_t screen, bool random)
18776 {
18777 bool blocked;
18778 2429 int32_t c=0;
18779 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18780
18781 2429 do
18782 {
18783
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18784 22928 int x = sle_x + offx;
18785 22928 int y = sle_y + offy;
18786
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18787
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18788
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18789
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18790 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18791
18792
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18793 1 return -1;
18794
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18795 11463 while(blocked);
18796
18797 2428 int32_t dir=0;
18798
18799
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18800
18801
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18802
18803
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18804
18805
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18806
18807 2428 return dir;
18808 2429 }
18809
18810 bool can_side_load(int32_t id)
18811 {
18812 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18813 {
18814 return false;
18815 }
18816
18817 id = id&0xFFF;
18818
18819 switch(guysbuf[id].family)
18820 {
18821 case eeTEK:
18822 case eeLEV:
18823 case eeAQUA:
18824 case eeDONGO:
18825 case eeMANHAN:
18826 case eeGLEEOK:
18827 case eeDIG:
18828 case eeGHOMA:
18829 case eeLANM:
18830 case eePATRA:
18831 case eeGANON:
18832 case eePROJECTILE:
18833 return false;
18834 break;
18835 }
18836
18837 return true;
18838 }
18839
18840 bool enemy_spawning_has_checked_been_here;
18841 static bool enemy_spawning_has_been_here;
18842
18843 34859 static bool check_if_recently_visited()
18844 {
18845
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34337 times.
34859 if (enemy_spawning_has_checked_been_here)
18846 522 return enemy_spawning_has_been_here;
18847
18848 34337 int mi = mapind(cur_map, cur_screen);
18849
18850 34337 enemy_spawning_has_been_here = false;
18851
2/2
✓ Branch 0 taken 206022 times.
✓ Branch 1 taken 34337 times.
240359 for (int i = 0; i < 6; i++)
18852
2/2
✓ Branch 0 taken 196482 times.
✓ Branch 1 taken 9540 times.
215562 if (visited[i] == mi)
18853 9540 enemy_spawning_has_been_here = true;
18854
18855
2/2
✓ Branch 0 taken 9540 times.
✓ Branch 1 taken 24797 times.
34337 if (!enemy_spawning_has_been_here)
18856 {
18857 24797 visited[vhead] = mi; //If not, it adds it to the array,
18858 24797 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18859 24797 }
18860
18861 34337 enemy_spawning_has_checked_been_here = true;
18862 34337 return enemy_spawning_has_been_here;
18863 34859 }
18864
18865 static std::array<bool, MAPSCRS> script_sle;
18866
18867 static int32_t sle_pattern = 0;
18868 static void script_side_load_enemies(mapscr* scr)
18869 {
18870 if (script_sle[scr->screen] || sle_clk) return;
18871
18872 sle_cnt = 0;
18873 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18874 ++sle_cnt;
18875 script_sle[scr->screen] = true;
18876 sle_pattern = scr->pattern;
18877 sle_clk = 0;
18878 }
18879
18880 54516 static void side_load_enemies(mapscr* scr)
18881 {
18882 54516 int screen = scr->screen;
18883
18884
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18885 {
18886 683 sle_pattern = scr->pattern;
18887 683 sle_cnt = 0;
18888 683 int32_t guycnt = 0;
18889
18890 683 int mi = mapind(cur_map, screen);
18891 683 bool reload=true;
18892 683 bool unbeatablereload = true;
18893
18894 683 load_default_enemies(scr);
18895
18896 683 bool beenhere = check_if_recently_visited();
18897
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18898 {
18899 42 sle_cnt=0;
18900 42 reload=false;
18901 42 }
18902
18903
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18904 {
18905 641 sle_cnt = game->guys[mi];
18906
18907
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18908 641 || sle_cnt==0)
18909 {
18910
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18911 1054 ++sle_cnt;
18912 221 }
18913
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18914 {
18915 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18916 {
18917 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18918 {
18919 unbeatablereload = false;
18920 }
18921 }
18922 if (unbeatablereload)
18923 {
18924 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18925 {
18926 ++sle_cnt;
18927 }
18928 }
18929 }
18930 641 }
18931
18932
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18933 {
18934 31 sle_cnt = 0;
18935
18936
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18937 108 ++sle_cnt;
18938 31 }
18939
1/2
✓ Branch 0 taken 683 times.
✗ Branch 1 not taken.
683 if(getmapflag(scr, mNO_ENEMIES_RETURN))
18940 sle_cnt = 0;
18941
18942
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18943 2446 ++guycnt;
18944
18945 683 game->guys[mi] = guycnt;
18946 683 }
18947
18948
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18949 {
18950 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18951 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18952
18953
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18954 {
18955 234 return;
18956 }
18957
18958 2195 int32_t enemy_slot=guys.Count();
18959
18960
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18961 sle_cnt--;
18962
18963
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18964 {
18965
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18966 {
18967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
18968 {
18969 2195 guys.spr(enemy_slot)->dir = dir;
18970 2195 }
18971
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18972 {
18973 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18974 {
18975 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18976 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18977 }
18978 }
18979 2195 }
18980 2195 }
18981 2195 }
18982
18983
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18984 {
18985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18986 script_sle[screen] = false;
18987 else
18988 {
18989 578 get_screen_state(screen).loaded_enemies = true;
18990 }
18991 578 sle_clk = 0;
18992 578 }
18993 54516 }
18994
18995 1252425 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18996 {
18997
2/2
✓ Branch 0 taken 116316 times.
✓ Branch 1 taken 1136109 times.
1252425 if (!is_in_scrolling_region())
18998
2/4
✓ Branch 0 taken 1136109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1136109 times.
1136109 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18999 {
19000 return false; //never 0, never OoB.
19001 }
19002 // No corner enemies
19003
6/6
✓ Branch 0 taken 1081534 times.
✓ Branch 1 taken 170891 times.
✓ Branch 2 taken 41257 times.
✓ Branch 3 taken 1122791 times.
✓ Branch 4 taken 117860 times.
✓ Branch 5 taken 94288 times.
1252425 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
19004 212148 return false;
19005
19006 //Is a no spawn combo...
19007
4/4
✓ Branch 0 taken 1122777 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1122783 times.
1122791 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19008 20 return false;
19009
19010 // No enemies in dungeon walls
19011
2/2
✓ Branch 0 taken 467839 times.
✓ Branch 1 taken 654944 times.
1122783 if (isdungeon(scr->screen))
19012 {
19013 654944 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
19014
17/18
✓ Branch 0 taken 654944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582384 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582384 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509824 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509824 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422752 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422752 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335680 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335680 times.
654944 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
19015 319264 return false;
19016 335680 }
19017
19018 // Too close to hero
19019
4/4
✓ Branch 0 taken 76958 times.
✓ Branch 1 taken 726561 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76857 times.
803519 if(tooclose(x,y,40) && t<11)
19020 76857 return false;
19021
19022 // Can't fly onto it?
19023
4/4
✓ Branch 0 taken 139610 times.
✓ Branch 1 taken 587052 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
787877 if(isflier(scr->enemy[i])&&
19024
2/2
✓ Branch 0 taken 139220 times.
✓ Branch 1 taken 390 times.
139610 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19025
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78005 times.
139220 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19026 25645 return false;
19027
19028 // Can't jump onto it?
19029 if
19030 (
19031
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
789725 guysbuf[scr->enemy[i]].family==eeTEK
19032
19033
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 612295 times.
701017 &&
19034 (
19035
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19036
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
19037
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
19038
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
19039 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19040 )
19041 )
19042 {
19043 18 return false;
19044 }
19045
19046 // Other off-limit combos
19047
6/6
✓ Branch 0 taken 587028 times.
✓ Branch 1 taken 113971 times.
✓ Branch 2 taken 498324 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276357 times.
✓ Branch 5 taken 221967 times.
1199323 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].family!=eeTEK &&
19048
2/2
✓ Branch 0 taken 281915 times.
✓ Branch 1 taken 216409 times.
498324 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19049 498324 guysbuf[scr->enemy[i]].family!=eeZORA)
19050 221967 return false;
19051
19052 // Don't ever generate enemies on these combos!
19053
4/4
✓ Branch 0 taken 478726 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478732 times.
479032 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19054 312 return false;
19055
19056 //BS Dodongos need at least 2 spaces.
19057
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477693 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478732 if ((guysbuf[scr->enemy[i]].family==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19058 {
19059
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19060
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19061
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19062 ((y>144)||_walkflag(x, y+24,2)))
19063 {
19064 return false;
19065 }
19066 19 }
19067
19068 478726 return true;
19069 1146357 }
19070
19071 159854 bool is_ceiling_pattern(int32_t i)
19072 {
19073
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 159834 times.
159854 return (i==pCEILING || i==pCEILINGR);
19074 }
19075
19076 5951 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19077 {
19078 5951 std::vector<rpos_t> freeposcache;
19079
19080
2/2
✓ Branch 0 taken 65461 times.
✓ Branch 1 taken 5951 times.
71412 for(int32_t y=offy; y<offy+176; y+=16)
19081 {
19082
2/2
✓ Branch 0 taken 1047376 times.
✓ Branch 1 taken 65461 times.
1112837 for(int32_t x=offx; x<offx+256; x+=16)
19083 {
19084
3/4
✓ Branch 0 taken 1047376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420983 times.
✓ Branch 3 taken 626393 times.
1047376 if(is_starting_pos(scr,i,x,y,0))
19085 {
19086
2/4
✓ Branch 0 taken 420983 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420983 times.
✗ Branch 3 not taken.
420983 freeposcache.push_back(COMBOPOS_REGION(x, y));
19087 420983 }
19088 1047376 }
19089 65461 }
19090
19091
2/2
✓ Branch 0 taken 5940 times.
✓ Branch 1 taken 11 times.
5951 if (!freeposcache.empty())
19092
1/2
✓ Branch 0 taken 5940 times.
✗ Branch 1 not taken.
5940 return freeposcache[zc_oldrand()%freeposcache.size()];
19093
19094 11 return rpos_t::None;
19095 5951 }
19096
19097 80738 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19098 {
19099 80738 int screen = scr->screen;
19100 80738 int x = 0;
19101 80738 int y = 0;
19102 80738 bool placed=false;
19103 80738 int32_t t=-1;
19104
19105 // First: enemy combo flags
19106
2/2
✓ Branch 0 taken 802694 times.
✓ Branch 1 taken 63694 times.
866388 for(int32_t sy=0; sy<176; sy+=16)
19107 {
19108
2/2
✓ Branch 0 taken 12716349 times.
✓ Branch 1 taken 785650 times.
13501999 for(int32_t sx=0; sx<256; sx+=16)
19109 {
19110 12716349 x = offx + sx;
19111 12716349 y = offy + sy;
19112 12716349 int32_t cflag = MAPFLAG(x, y);
19113 12716349 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19114
19115
2/4
✓ Branch 0 taken 12716349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12716349 times.
✗ Branch 3 not taken.
12716349 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19116 {
19117 if(!ok2add(scr, scr->enemy[i]))
19118 {
19119 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19120 }
19121 else
19122 {
19123 addenemy_z(screen,x,
19124 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19125 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19126
19127 ++guycnt;
19128
19129 placed=true;
19130 goto placed_enemy;
19131 }
19132 }
19133
19134
4/4
✓ Branch 0 taken 12699256 times.
✓ Branch 1 taken 17093 times.
✓ Branch 2 taken 12699256 times.
✓ Branch 3 taken 17093 times.
12716349 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19135 {
19136
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17044 times.
17093 if(!ok2add(scr, scr->enemy[i]))
19137 {
19138
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19139 49 }
19140 else
19141 {
19142 34088 addenemy_z(screen,x,
19143
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17043 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17044 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19144
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17043 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17044 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19145
19146 17044 ++guycnt;
19147
19148 17044 placed=true;
19149 17044 goto placed_enemy;
19150 }
19151 49 }
19152 12699305 }
19153 785650 }
19154
19155 // Next: enemy pattern
19156
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58697 times.
✓ Branch 2 taken 57960 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 57960 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57960 times.
63694 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19157 {
19158 57960 do
19159 {
19160
19161 // NES positions
19162 99198 pos%=9;
19163 99198 x=offx+stx[loadside][pos];
19164 99198 y=offy+sty[loadside][pos];
19165 99198 ++pos;
19166 99198 ++t;
19167
2/2
✓ Branch 0 taken 41238 times.
✓ Branch 1 taken 57960 times.
157158 }
19168
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 98981 times.
99198 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19169 57960 }
19170
19171
4/4
✓ Branch 0 taken 57960 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 217 times.
✓ Branch 3 taken 57743 times.
63694 if(t<0 || t >= 20) // above enemy pattern failed
19172 {
19173 // Final chance: find a random position anywhere onscreen
19174 5951 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19175
19176
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5940 times.
5951 if (rand_rpos != rpos_t::None)
19177 {
19178 5940 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19179 5940 }
19180 else // All opportunities failed - abort
19181 {
19182 11 return;
19183 }
19184 5940 }
19185
19186 {
19187 63683 int32_t c=0;
19188 63683 c=clk;
19189
19190
2/2
✓ Branch 0 taken 9615 times.
✓ Branch 1 taken 54068 times.
63683 if(!slowguy(scr->enemy[i]))
19191 54068 ++fastguys;
19192
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8029 times.
9615 else if(fastguys>0)
19193 1586 c=-15*(i-fastguys+2);
19194 else
19195 8029 c=-15*(i+1);
19196
19197
4/6
✓ Branch 0 taken 29090 times.
✓ Branch 1 taken 34593 times.
✓ Branch 2 taken 29090 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29090 times.
63683 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19198 {
19199 // Special case for blue leevers
19200
4/4
✓ Branch 0 taken 1866 times.
✓ Branch 1 taken 27224 times.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 1116 times.
29090 if(guysbuf[scr->enemy[i]].family==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19201 750 c=-15*(i+1);
19202 else
19203 28340 c=-15;
19204 29090 }
19205
19206
2/2
✓ Branch 0 taken 62883 times.
✓ Branch 1 taken 800 times.
63683 if(!ok2add(scr, scr->enemy[i]))
19207 {
19208
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19209 800 }
19210 else
19211 {
19212
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62883 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62883 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19213 {
19214
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62707 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125766 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19215
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62707 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62883 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19216
19217 62883 ++guycnt;
19218 62883 }
19219 }
19220
19221 63683 placed=true;
19222 63683 } // if(t < 20)
19223
19224 placed_enemy:
19225
19226 // I don't like this, but it seems to work...
19227 static bool foundCarrier;
19228
19229
2/2
✓ Branch 0 taken 59235 times.
✓ Branch 1 taken 21492 times.
80727 if(i==0)
19230 21492 foundCarrier=false;
19231
19232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80727 times.
80727 if(placed)
19233 {
19234
4/4
✓ Branch 0 taken 21492 times.
✓ Branch 1 taken 59235 times.
✓ Branch 2 taken 21323 times.
✓ Branch 3 taken 169 times.
80727 if(i==0 && scr->flags11&efLEADER)
19235 {
19236 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19237
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19238 {
19239 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19240
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19241 {
19242 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19243 }
19244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19245 {
19246 162 e->leader = true;
19247 162 }
19248 162 }
19249 169 }
19250
19251 80727 ScreenItemState item_state = get_screen_state(screen).item_state;
19252
5/6
✓ Branch 0 taken 80485 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 80485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 80408 times.
80727 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19253 {
19254 77 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19255
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if (e && (e->flags&guy_doesnt_count)==0)
19256 {
19257 77 e->itemguy = true;
19258 77 foundCarrier=true;
19259 77 }
19260 77 }
19261 80727 }
19262 80738 }
19263
19264 // returns index of first sprite with matching id, -1 if none found
19265 246 enemy* find_guy_first_for_id(int screen, int id, int mask)
19266 {
19267 246 int count = guys.Count();
19268
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 7 times.
373 for (int32_t i=0; i<count; i++)
19269 {
19270 366 enemy* e = (enemy*)guys.spr(i);
19271
4/4
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 79 times.
366 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19272 {
19273 239 return e;
19274 }
19275 127 }
19276
19277 7 return nullptr;
19278 246 }
19279
19280 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19281 {
19282 int count = guys.Count();
19283 for(int32_t i=0; i<count; i++)
19284 {
19285 enemy* e = (enemy*)guys.spr(i);
19286 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19287 {
19288 if (n > 1) --n;
19289 else return e;
19290 }
19291 }
19292 return nullptr;
19293 }
19294
19295 bool scriptloadenemies(int screen)
19296 {
19297 if (sle_clk || script_sle[screen]) return false;
19298
19299 mapscr* scr = get_scr(screen);
19300 if(scr->pattern==pNOSPAWN) return false;
19301
19302 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19303 {
19304 script_side_load_enemies(scr);
19305 return true;
19306 }
19307
19308 auto [x, y] = translate_screen_coordinates_to_world(screen);
19309 int32_t pos=zc_oldrand()%9;
19310 int32_t clk=-15,fastguys=0;
19311 int32_t i=0,guycnt=0;
19312 int32_t loadcnt = 10;
19313
19314 for(; i<loadcnt && scr->enemy[i]>0; i++)
19315 {
19316 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19317 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19318 if (guys.Count() > preguycount)
19319 {
19320 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19321 {
19322 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19323 {
19324 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19325 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19326 }
19327 }
19328 }
19329 --clk;
19330 }
19331 return true;
19332 }
19333
19334 14195428 void loadenemies()
19335 {
19336 28771014 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19337 14575586 int screen = scr->screen;
19338 14575586 auto& state = get_screen_state(screen);
19339
2/2
✓ Branch 0 taken 14160549 times.
✓ Branch 1 taken 415037 times.
14575586 if (state.loaded_enemies)
19340 14160549 return;
19341
19342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415037 times.
415037 if(getmapflag(scr, mNO_ENEMIES_RETURN))
19343 return;
19344
19345 // dungeon basements
19346 static byte dngn_enemy_x[4] = {32,96,144,208};
19347
2/2
✓ Branch 0 taken 148963 times.
✓ Branch 1 taken 266074 times.
415037 if (cur_screen>=128)
19348 {
19349
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 474 times.
148963 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19351 {
19352 for(int32_t i=0; i<10; i++)
19353 {
19354 if ( scr->enemy[i] )
19355 {
19356 int32_t preguycount = guys.Count();
19357 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19358 if (guys.Count() > preguycount)
19359 {
19360 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19361 {
19362 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19363 {
19364 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19365 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19366 }
19367 }
19368 }
19369 }
19370 }
19371 }
19372 else
19373 {
19374
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 474 times.
2370 for(int32_t i=0; i<4; i++)
19375 {
19376 1896 int32_t preguycount = guys.Count();
19377
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 852 times.
1896 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if (guys.Count() > preguycount)
19379 {
19380
2/2
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 4 times.
1896 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19381 {
19382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19383 {
19384 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19385 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19386 4 }
19387 4 }
19388 1896 }
19389 1896 }
19390 }
19391
19392 474 state.loaded_enemies = true;
19393 474 return;
19394 }
19395
19396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266074 times.
266074 if (scr->pattern == pNOSPAWN)
19397 return;
19398
19399 // TODO: configure when screen enemies spawn.
19400
2/2
✓ Branch 0 taken 88782 times.
✓ Branch 1 taken 177292 times.
266074 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19401 177292 return;
19402
19403
4/4
✓ Branch 0 taken 50335 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34266 times.
88782 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19404 {
19405 54516 side_load_enemies(scr);
19406 54516 return;
19407 }
19408
19409 34266 state.loaded_enemies = true;
19410
19411 // check if it's the dungeon boss and it has been beaten before
19412
4/4
✓ Branch 0 taken 356 times.
✓ Branch 1 taken 33910 times.
✓ Branch 2 taken 266 times.
✓ Branch 3 taken 90 times.
34266 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&liBOSS)
19413 90 return;
19414
19415 34176 int32_t loadcnt = 10;
19416 34176 int16_t mi = mapind(cur_map, screen);
19417 34176 bool beenhere = check_if_recently_visited();
19418
19419 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19420 34176 bool reload = true;
19421
4/4
✓ Branch 0 taken 9683 times.
✓ Branch 1 taken 24493 times.
✓ Branch 2 taken 4688 times.
✓ Branch 3 taken 4995 times.
34176 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19422 {
19423 4995 loadcnt = 0; //It will tell it not to load any enemies,
19424 4995 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19425 4995 }
19426
19427 34176 bool unbeatablereload = true;
19428
2/2
✓ Branch 0 taken 4995 times.
✓ Branch 1 taken 29181 times.
34176 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19429 {
19430 29181 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19431
19432
2/4
✓ Branch 0 taken 10209 times.
✓ Branch 1 taken 18972 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29181 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10209 times.
10209 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19434 18972 loadcnt = 10; //That means all enemies need to be respawned.
19435
3/4
✓ Branch 0 taken 24493 times.
✓ Branch 1 taken 4688 times.
✓ Branch 2 taken 24493 times.
✗ Branch 3 not taken.
29181 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19436 {
19437 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19438 {
19439 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19440 {
19441 unbeatablereload = false;
19442 }
19443 }
19444 if (unbeatablereload)
19445 {
19446 loadcnt = 10;
19447 }
19448 }
19449 29181 }
19450
19451
4/4
✓ Branch 0 taken 32715 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 191 times.
✓ Branch 3 taken 32524 times.
34176 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19452 1652 loadcnt = 10; //All enemies also need to be respawned.
19453
19454 // do enemies that are always loaded
19455 34176 load_default_enemies(scr);
19456 34176 activate_fireball_statues(scr);
19457
19458 34176 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19459 34176 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19460 34176 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19461
4/4
✓ Branch 0 taken 15057 times.
✓ Branch 1 taken 99857 times.
✓ Branch 2 taken 80738 times.
✓ Branch 3 taken 34176 times.
114914 for(; i<loadcnt && scr->enemy[i]>0; i++)
19462 {
19463 80738 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19464 80738 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19465
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 79927 times.
80738 if (guys.Count() > preguycount)
19466 {
19467
2/2
✓ Branch 0 taken 77575 times.
✓ Branch 1 taken 2352 times.
79927 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19468 {
19469
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2348 times.
2352 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19470 {
19471 2348 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19472 2348 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19473 2348 }
19474 2352 }
19475 79927 }
19476
19477 80738 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19478 80738 }
19479
19480 34176 game->guys[mi] = guycnt;
19481 14575586 });
19482 14195428 }
19483
19484 233 void moneysign()
19485 {
19486 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19487 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19488 233 set_clip_state(pricesdisplaybuf, 0);
19489 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19490 233 }
19491
19492 3300 void putprices(bool sign)
19493 {
19494
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3268 times.
3300 if(fadeclk > 0) return;
19495
19496 3268 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19497 3268 int32_t step=32;
19498 3268 int32_t x=80;
19499
19500
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2987 times.
3268 if(prices[2]==0)
19501 {
19502 2987 step<<=1;
19503
19504
2/2
✓ Branch 0 taken 2955 times.
✓ Branch 1 taken 32 times.
2987 if(prices[1]==0)
19505 {
19506 2955 x=112;
19507 2955 }
19508 2987 }
19509
19510
2/2
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 9804 times.
13072 for(int32_t i=0; i<3; i++)
19511 {
19512 // Kind of stupid, but it works: 100000 is used to indicate that an item
19513 // has a price of zero rather than there being no item.
19514 // 100000 isn't a valid price, so this doesn't cause problems.
19515
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8765 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9804 if(prices[i]!=0 && prices[i]<100000)
19516 {
19517 char buf[8];
19518 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19519
19520 1039 int32_t l=(int32_t)strlen(buf);
19521 1039 set_clip_state(pricesdisplaybuf, 0);
19522
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19523 1039 }
19524
19525 9804 x+=step;
19526 9804 }
19527 3300 }
19528
19529 // Setting up special rooms
19530 // Also called when the Letter is used successfully.
19531 1207 void setupscreen()
19532 {
19533 1207 boughtsomething=false;
19534
19535 // Either the origin screen, or if in a 0x80 room the screen player came from.
19536
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 791 times.
1207 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19537 1207 mapscr* scr = origin_scr;
19538
19539 1207 word str=base_scr->str;
19540
19541 2259 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19542
19543 // Prices are already set to 0 in dowarp()
19544
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 686 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1207 switch(base_scr->room)
19545 {
19546 case rSP_ITEM: // special item
19547 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19548 164 break;
19549
19550 case rINFO: // pay for info
19551 {
19552 28 int32_t count = 0;
19553 28 int32_t base = 88;
19554 28 int32_t step = 5;
19555
19556 28 moneysign();
19557
19558
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19559 {
19560
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19561 {
19562 84 ++count;
19563 84 }
19564 else
19565 break;
19566 84 }
19567
19568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19569 {
19570
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19571 {
19572 base = 88+32;
19573 }
19574
19575
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19576 {
19577 step = 6;
19578 }
19579
19580
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19581 {
19582 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19583 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19584 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19585
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19586 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19587 84 int32_t itemid = current_item_id(itype_wealthmedal);
19588
19589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19590 {
19591 if(itemsbuf[itemid].flags & item_flag1)
19592 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19593 else
19594 prices[i]-=itemsbuf[itemid].misc1;
19595 prices[i]=vbound(prices[i], -99999, 0);
19596 if(prices[i]==0)
19597 prices[i]=100000;
19598 }
19599
19600
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19601 prices[i]=-1;
19602 84 }
19603 28 }
19604
19605 28 break;
19606 }
19607
19608 case rMONEY: // secret money
19609 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19610 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19611 44 break;
19612
19613 case rGAMBLE: // gambling
19614 11 prices[0]=prices[1]=prices[2]=-10;
19615 11 moneysign();
19616 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19617 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19618 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19619 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19620 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19621 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19622 11 break;
19623
19624 case rREPAIR: // door repair
19625
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19626 // }
19627 13 repaircharge=base_scr->catchall;
19628 13 break;
19629
19630 case rMUPGRADE: // upgrade magic
19631 2 adjustmagic=true;
19632 2 break;
19633
19634 case rLEARNSLASH: // learn slash attack
19635 2 learnslash=true;
19636 2 break;
19637
19638 case rRP_HC: // heart container or red potion
19639 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19640 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19641 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19642 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19643 17 break;
19644
19645 case rP_SHOP: // potion shop
19646
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19647 {
19648 12 str=0;
19649 12 break;
19650 }
19651
19652 [[fallthrough]];
19653 case rTAKEONE: // take one
19654 case rSHOP: // shop
19655 {
19656 194 int32_t count = 0;
19657 194 int32_t base = 88;
19658 194 int32_t step = 5;
19659
19660
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19661 193 moneysign();
19662
19663 //count and align the stuff
19664
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19665 {
19666
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19667 {
19668 523 ++count;
19669 523 }
19670 else
19671 {
19672 37 break;
19673 }
19674 523 }
19675
19676
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19677 {
19678 22 base = 88+32;
19679 22 }
19680
19681
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19682 {
19683 15 step = 6;
19684 15 }
19685
19686
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19687 {
19688 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19689 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19690
19691
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19692 {
19693 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19694
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19695 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19696 521 int32_t itemid = current_item_id(itype_wealthmedal);
19697
19698
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19699 {
19700
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19701 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19702 else
19703 prices[i]+=itemsbuf[itemid].misc1;
19704 9 prices[i]=vbound(prices[i], 0, 99999);
19705
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19706 prices[i]=100000;
19707 9 }
19708
19709
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19710 prices[i]=1;
19711 521 }
19712 523 }
19713
19714 194 break;
19715 }
19716 case rBOTTLESHOP: // bottle shop
19717 {
19718 1 int32_t count = 0;
19719 1 int32_t base = 88;
19720 1 int32_t step = 5;
19721
19722 1 moneysign();
19723 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19724 //count and align the stuff
19725
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19726 {
19727
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19728 {
19729 3 ++count;
19730 3 }
19731 else
19732 {
19733 break;
19734 }
19735 3 }
19736
19737
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19738 {
19739 base = 88+32;
19740 }
19741
19742
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19743 {
19744 step = 6;
19745 }
19746
19747
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19748 {
19749 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19750 //{ Setup dummy item
19751 3 item* curItem = ((item*)items.spr(items.Count()-1));
19752 3 curItem->PriceIndex = i;
19753 3 newcombo const& cmb = combobuf[bst.comb[i]];
19754
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19755 {
19756 curItem->yofs = -32768;
19757 }
19758 3 curItem->o_tile = cmb.o_tile;
19759 3 curItem->o_cset = bst.cset[i];
19760 3 curItem->cs = curItem->o_cset;
19761 3 curItem->tile = cmb.o_tile;
19762 3 curItem->o_speed = cmb.speed;
19763 3 curItem->o_delay = 0;
19764 3 curItem->frames = cmb.frames;
19765 3 curItem->flip = cmb.flip;
19766 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19767 3 curItem->pstring = 0;
19768 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19769 3 curItem->flash = false;
19770 3 curItem->twohand = false;
19771 3 curItem->anim = true;
19772 3 curItem->hit_width=1;
19773 3 curItem->hyofs=4;
19774 3 curItem->hit_height=12;
19775 3 curItem->script=0;
19776 3 curItem->txsz=1;
19777 3 curItem->tysz=1;
19778 //}
19779
19780 3 prices[i] = bst.price[i];
19781
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19782 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19783 3 int32_t itemid = current_item_id(itype_wealthmedal);
19784
19785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19786 {
19787 if(itemsbuf[itemid].flags & item_flag1)
19788 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19789 else
19790 prices[i]+=itemsbuf[itemid].misc1;
19791 prices[i]=vbound(prices[i], 0, 99999);
19792 if(prices[i]==0)
19793 prices[i]=100000;
19794 }
19795
19796
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19797 prices[i]=1;
19798 3 }
19799
19800 1 break;
19801 }
19802
19803 case rBOMBS: // more bombs
19804 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19805 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19806 19 prices[0]=-base_scr->catchall;
19807 19 break;
19808
19809 case rARROWS: // more arrows
19810 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19811 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19812 prices[0]=-base_scr->catchall;
19813 break;
19814
19815 case rSWINDLE: // leave heart container or money
19816 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19817 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19818 14 prices[0]=-1;
19819 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19820 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19821 14 prices[1]=-base_scr->catchall;
19822 14 break;
19823
19824 }
19825
19826
3/4
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1188 times.
1207 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19827 {
19828 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19829 19 int32_t itemid = current_item_id(itype_wealthmedal);
19830
19831
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19832 {
19833 if(itemsbuf[itemid].flags & item_flag1)
19834 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19835 else
19836 prices[i]+=itemsbuf[itemid].misc1;
19837 }
19838
19839
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19840 prices[i]=-1;
19841 19 }
19842
19843 1207 putprices(false);
19844
19845
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 59 times.
1207 if(str)
19846 {
19847 1148 donewmsg(base_scr, str);
19848 1148 }
19849 else
19850 {
19851 59 Hero.unfreeze();
19852 }
19853 1207 }
19854
19855 enum
19856 {
19857 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19858 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19859
19860 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19861
19862 MNU_DATA_MAX
19863 };
19864 struct menu_choice
19865 {
19866 int32_t x, y;
19867 int32_t pos;
19868 int32_t upos, dpos, lpos, rpos;
19869 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19870 18 {}
19871 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19872 int32_t dpos, int32_t lpos, int32_t rpos)
19873 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19874 18 {}
19875 };
19876 static int32_t msg_menu_data[MNU_DATA_MAX];
19877 static bool do_run_menu = false;
19878 bool do_end_str = false;
19879 static bool wait_advance = false;
19880 415 static std::map<int32_t, menu_choice> menu_options;
19881 43681 void clr_msg_data()
19882 {
19883 43681 do_end_str = false;
19884 43681 wait_advance = false;
19885 43681 do_run_menu = false;
19886 43681 menu_options.clear();
19887 43681 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19888 43681 }
19889
19890 static char namebuf[9] = {0};
19891 static char* nameptr = NULL;
19892 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19893 2036 bool runMenuCursor()
19894 {
19895 2036 clear_bitmap(msg_menu_bmp_buf);
19896
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19897 {
19898 msg_menu_data[MNU_CHOSEN] = 0;
19899 return true; //end menu
19900 }
19901 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19902 //If the cursor is at an invalid pos, find the first pos >= 0...
19903
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19904 {
19905 pos = 0;
19906 while(menu_options.find(pos) == menu_options.end())
19907 ++pos;
19908 }
19909 2036 menu_choice* ch = &menu_options[pos];
19910
19911 2036 bool pressed = true;
19912
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19913
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19914
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19915
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19916 2010 else pressed = false;
19917
19918
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19919 26 msg_menu_data[MNU_TIMER] = 1;
19920
19921 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19922 2036 bool held = false;
19923
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19924 {
19925 90 held = true;
19926
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19930 89 else held = false;
19931 90 }
19932 //If the cursor is at an invalid pos, find the first pos >= 0...
19933
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19934 {
19935 pos = 0;
19936 while(menu_options.find(pos) == menu_options.end())
19937 ++pos;
19938 }
19939
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19940 27 sfx(MsgStrings[msgstr].sfx);
19941
19942 2036 ch = &menu_options[pos];
19943 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19944 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19945 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19946 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19947
19948 2036 msg_menu_data[MNU_CHOSEN] = pos;
19949
19950
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19951 {
19952 603 rAbtn(); //Eat
19953
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19954 603 }
19955
19956
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
19957 //Eat inputs
19958 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19959
19960
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
19961 5 menu_options.clear();
19962
19963 2036 return ret;
19964 //false if pos changed this frame; no confirming while moving the cursor!
19965 2036 }
19966
19967 839481 bool bottom_margin_clip()
19968 {
19969 891318 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19970
2/2
✓ Branch 0 taken 787644 times.
✓ Branch 1 taken 51837 times.
839481 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19971 }
19972
19973 void update_msgstr();
19974
19975 3293 static bool parsemsgcode(const StringCommand& command)
19976 {
19977 3293 auto& args = command.args;
19978 3293 int last_arg = 0;
19979
19980
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
19981 {
19982 case MSGC_NEWLINE:
19983 {
19984 1280 ssc_tile_hei = ssc_tile_hei_buf;
19985
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19986 1280 ssc_tile_hei_buf = -1;
19987 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19988 1280 cursor_x=msg_margins[left];
19989 1280 return true;
19990 }
19991
19992 case MSGC_COLOUR:
19993 {
19994 1644 int32_t cset = args[0];
19995 1644 msgcolour = CSET(cset)+(args[1]);
19996 1644 return true;
19997 }
19998
19999 case MSGC_SHDCOLOR:
20000 {
20001 int32_t cset = args[0];
20002 msg_shdcol = CSET(cset)+args[1];
20003 return true;
20004 }
20005 case MSGC_SHDTYPE:
20006 {
20007 msg_shdtype = args[0];
20008 return true;
20009 }
20010
20011 case MSGC_SPEED:
20012 {
20013 56 msgspeed=args[0];
20014 56 return true;
20015 }
20016
20017 case MSGC_CTRUP:
20018 {
20019 int32_t a1 = args[0];
20020 int32_t a2 = args[1];
20021 game->change_counter(a2, a1);
20022 return true;
20023 }
20024
20025 case MSGC_CTRDN:
20026 {
20027 5 int32_t a1 = args[0];
20028 5 int32_t a2 = args[1];
20029 5 game->change_counter(-a2, a1);
20030 5 return true;
20031 }
20032
20033 case MSGC_CTRSET:
20034 {
20035 7 int32_t a1 = args[0];
20036 7 int32_t a2 = args[1];
20037 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20038 7 return true;
20039 }
20040
20041 case MSGC_CTRUPPC:
20042 case MSGC_CTRDNPC:
20043 case MSGC_CTRSETPC:
20044 {
20045 2 int32_t counter = args[0];
20046 2 int32_t amount = args[1];
20047 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20048
20049
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20050 amount*=-1;
20051
20052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20053 game->set_counter(amount, counter);
20054 else
20055 2 game->change_counter(amount, counter);
20056
20057 2 return true;
20058 }
20059
20060 case MSGC_GIVEITEM:
20061 {
20062 70 int32_t itemID = args[0];
20063
20064 70 getitem(itemID, true);
20065
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20066 {
20067 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20068 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20069 70 }
20070 70 return true;
20071 }
20072
20073
20074 case MSGC_WARP:
20075 {
20076 int32_t dmap = args[0];
20077 int32_t scrn = args[1];
20078 int32_t dx = args[2];
20079 int32_t dy = args[3];
20080 int32_t wfx = args[4];
20081 int32_t sfx = args[5];
20082 if(dx >= MAX_SCC_ARG) dx = -1;
20083 if(dy >= MAX_SCC_ARG) dy = -1;
20084 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20085 do_end_str = true;
20086 return true;
20087 }
20088
20089 case MSGC_SETSCREEND:
20090 {
20091 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20092 int32_t screen = args[1];
20093 int32_t reg = args[2];
20094 int32_t val = args[3];
20095 FFCore.set_screen_d(screen + dmap, reg, val);
20096 return true;
20097 }
20098 case MSGC_TAKEITEM:
20099 {
20100 11 int32_t itemID = args[0];
20101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20102 {
20103 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20104 }
20105 11 takeitem(itemID);
20106
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20107 {
20108 game->forced_bwpn = -1;
20109 } //not else if! -Z
20110
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20111 {
20112 game->forced_awpn = -1;
20113 }
20114
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20115 {
20116 game->forced_xwpn = -1;
20117 } //not else if! -Z
20118
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20119 {
20120 game->forced_ywpn = -1;
20121 }
20122 11 verifyBothWeapons();
20123 11 return true;
20124 }
20125
20126 case MSGC_SFX:
20127 {
20128 22 sfx(args[0],128);
20129 22 return true;
20130 }
20131
20132 case MSGC_MIDI:
20133 {
20134 7 int32_t music = args[0];
20135
20136
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20137 1 music_stop();
20138 else
20139 6 jukebox(music+(ZC_MIDI_COUNT-1));
20140
20141 7 return true;
20142 }
20143
20144 case MSGC_FONT:
20145 {
20146 int fontid = args[0];
20147 int oh = text_height(msgfont);
20148 msgfont = get_zc_font(fontid);
20149 int nh = text_height(msgfont);
20150 int mh = std::max(oh,nh);
20151 if(mh > ssc_tile_hei_buf)
20152 ssc_tile_hei_buf = mh;
20153 return true;
20154 }
20155 case MSGC_RUN_FRZ_GENSCR:
20156 {
20157 word scr_id = args[0];
20158 bool force_redraw = args[1]!=0;
20159 if(force_redraw)
20160 {
20161 update_msgstr();
20162 draw_screen();
20163 }
20164 FFCore.runGenericFrozenEngine(scr_id);
20165 return true;
20166 }
20167 case MSGC_DRAWTILE:
20168 {
20169 int32_t tl = args[0];
20170 int32_t cs = args[1];
20171 int32_t t_wid = args[2];
20172 int32_t t_hei = args[3];
20173 int32_t fl = args[4];
20174
20175 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20176 {
20177 ssc_tile_hei = ssc_tile_hei_buf;
20178 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20179 ssc_tile_hei_buf = -1;
20180 cursor_y += thei + MsgStrings[msgstr].vspace;
20181 if(bottom_margin_clip()) return true;
20182 cursor_x=msg_margins[left];
20183 }
20184
20185 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20186 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20187 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20188 return true;
20189 }
20190
20191 case MSGC_GOTOIFRAND:
20192 {
20193 1 int32_t odds = args[0];
20194
20195 1 last_arg = 1;
20196
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20197 1 goto switched;
20198
20199 return true;
20200 }
20201
20202 case MSGC_GOTOIFGLOBAL:
20203 {
20204 int32_t arg = args[0];
20205 int32_t d = zc_min(7,arg);
20206 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20207 arg = args[1];
20208
20209 if(game->screen_d[s][d] >= arg)
20210 {
20211 last_arg = 2;
20212 goto switched;
20213 }
20214
20215 return true;
20216 }
20217
20218 case MSGC_CHANGEPORTRAIT:
20219 {
20220 return true; //not implemented
20221 }
20222
20223 case MSGC_GOTOIFCREEND:
20224 {
20225 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20226 int32_t screen = args[1];
20227 int32_t reg = args[2];
20228 int32_t val = args[3];
20229 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20230 {
20231 last_arg = 4;
20232 goto switched;
20233 }
20234 return true;
20235 }
20236
20237 case MSGC_GOTOIF:
20238 {
20239 122 int32_t it = args[0];
20240
20241
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20242 {
20243 35 last_arg = 1;
20244 35 goto switched;
20245 }
20246
20247 87 return true;
20248 }
20249
20250 case MSGC_GOTOIFCTR:
20251 {
20252
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20253 {
20254 14 last_arg = 2;
20255 14 goto switched;
20256 }
20257
20258 14 return true;
20259 }
20260
20261 case MSGC_GOTOIFCTRPC:
20262 {
20263 int32_t counter = args[0];
20264 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20265
20266 if(game->get_counter(counter)>=amount)
20267 {
20268 last_arg = 2;
20269 goto switched;
20270 }
20271
20272 return true;
20273 }
20274
20275 case MSGC_GOTOIFTRICOUNT:
20276 {
20277 if(TriforceCount() >= args[0])
20278 {
20279 last_arg = 1;
20280 goto switched;
20281 }
20282
20283 return true;
20284 }
20285
20286 case MSGC_GOTOIFTRI:
20287 {
20288 int32_t lev = args[0];
20289
20290 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20291 {
20292 last_arg = 1;
20293 goto switched;
20294 }
20295
20296 return true;
20297 }
20298
20299 case MSGC_SETUPMENU:
20300 {
20301 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20302 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20303 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20304 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20305 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20306 5 return true;
20307 }
20308
20309 case MSGC_MENUCHOICE:
20310 {
20311 18 int32_t pos = args[0];
20312 18 int32_t upos = args[1];
20313 18 int32_t dpos = args[2];
20314 18 int32_t lpos = args[3];
20315 18 int32_t rpos = args[4];
20316
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20317 {
20318 2 ssc_tile_hei = ssc_tile_hei_buf;
20319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20320 2 ssc_tile_hei_buf = -1;
20321 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20323 2 cursor_x=msg_margins[left];
20324 2 }
20325
20326 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20327 18 upos, dpos, lpos, rpos);
20328
20329
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20330 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20331 18 return true;
20332 }
20333
20334 case MSGC_RUNMENU:
20335 {
20336 5 msg_menu_data[MNU_CHOSEN] = 0;
20337 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20339 return true;
20340 5 do_run_menu = true;
20341 5 return true;
20342 }
20343
20344 case MSGC_GOTOMENUCHOICE:
20345 {
20346 7 int32_t choice = args[0];
20347
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20348 {
20349 5 last_arg = 1;
20350 5 goto switched;
20351 }
20352
20353 2 return true;
20354 }
20355
20356 case MSGC_ENDSTRING:
20357 {
20358 3 do_end_str = true;
20359 3 return true;
20360 }
20361 case MSGC_WAIT_ADVANCE:
20362 {
20363 wait_advance = true;
20364 linkedmsgclk = 51;
20365 return true;
20366 }
20367 case MSGC_TRIGSECRETS:
20368 {
20369 bool perm = args[0];
20370 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20371 if(perm)
20372 setmapflag(msgscr, mSECRET);
20373 return true;
20374 }
20375 case MSGC_TRIG_CMB_COPYCAT:
20376 {
20377 int copy_id = args[0];
20378 if(copy_id == byte(copy_id))
20379 trig_copycat(copy_id);
20380 return true;
20381 }
20382 case MSGC_SETSCREENSTATE:
20383 {
20384 int32_t flag = args[0];
20385 if(unsigned(flag)>=mMAXIND)
20386 {
20387 Z_error("SCC 133: Flag %d is invalid\n", flag);
20388 return true;
20389 }
20390 bool state = args[1];
20391 if(state)
20392 setmapflag(msgscr, 1<<flag);
20393 else
20394 unsetmapflag(msgscr, 1<<flag, true);
20395 return true;
20396 }
20397 case MSGC_SETSCREENSTATER:
20398 {
20399 int32_t map = args[0];
20400 int32_t scrid = args[1];
20401 if(map < 1 || map > map_count)
20402 {
20403 Z_error("SCC 134: Map %d is invalid\n", map);
20404 return true;
20405 }
20406 if(unsigned(scrid)>=0x80)
20407 {
20408 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20409 return true;
20410 }
20411
20412 int32_t flag = args[2];
20413 if(unsigned(flag)>=mMAXIND)
20414 {
20415 Z_error("SCC 134: Flag %d is invalid\n", flag);
20416 return true;
20417 }
20418 bool state = args[3];
20419 if(state)
20420 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20421 else
20422 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20423 return true;
20424 }
20425 switched:
20426 55 int32_t lev = args[last_arg];
20427
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20428
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20429 {
20430 setmsg(lev);
20431 }
20432 else
20433 {
20434 55 donewmsg(msgscr, lev);
20435 55 ssc_tile_hei_buf = -1;
20436 }
20437 55 putprices(false);
20438 55 return true;
20439 }
20440
20441 return false;
20442 3293 }
20443
20444 3299 static std::string parsemsgcode2(const StringCommand& command)
20445 {
20446
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20447 {
20448
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20449 }
20450 else
20451 {
20452 3293 parsemsgcode(command);
20453 }
20454
20455
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20456 3299 }
20457
20458 252553 static bool putmsgchar(bool play_sfx)
20459 {
20460 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20461 DCHECK(!msg_it->character.empty());
20462
20463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252553 times.
252553 if (bottom_margin_clip())
20464 return false;
20465
20466 // If the current word would overflow the margins, increment cursor to the next line.
20467 252553 const char* rem_word = msg_it->remaining_word();
20468 252553 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20469
4/4
✓ Branch 0 taken 5667 times.
✓ Branch 1 taken 246886 times.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 5077 times.
258128 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20470
4/4
✓ Branch 0 taken 5575 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5077 times.
✓ Branch 3 taken 92 times.
5667 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20471 {
20472 5575 ssc_tile_hei = ssc_tile_hei_buf;
20473
1/2
✓ Branch 0 taken 5575 times.
✗ Branch 1 not taken.
5575 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20474 5575 ssc_tile_hei_buf = -1;
20475 5575 cursor_y += thei + MsgStrings[msgstr].vspace;
20476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5575 times.
5575 if (bottom_margin_clip()) return false;
20477
20478 5575 cursor_x = msg_margins[left];
20479 5575 }
20480
20481
2/2
✓ Branch 0 taken 34904 times.
✓ Branch 1 taken 217649 times.
252553 if (play_sfx)
20482 217649 sfx(MsgStrings[msgstr].sfx);
20483
20484 // Print the character (unless it's just a space).
20485
2/2
✓ Branch 0 taken 58937 times.
✓ Branch 1 taken 193616 times.
252553 if (msg_it->character != " ")
20486 193616 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20487
20488 // Move the cursor.
20489 252553 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20490
2/2
✓ Branch 0 taken 58937 times.
✓ Branch 1 taken 193616 times.
252553 if (msg_it->character != " ")
20491 193616 cursor_x += MsgStrings[msgstr].hspace;
20492
20493 252553 return true;
20494 252553 }
20495
20496 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20497
20498 static void msg_tick_end(bool disappear = false);
20499 241666 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20500 {
20501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241666 times.
241666 if (msg_it->done())
20502 return msg_tick_exit;
20503
20504
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239635 times.
241666 if (!do_run_menu)
20505 {
20506
4/4
✓ Branch 0 taken 239635 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 3299 times.
✓ Branch 3 taken 239635 times.
242934 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20507 {
20508 3299 bool one_frame_command_delay = !replay_version_check(41);
20509 3299 std::string text = parsemsgcode2(msg_it->command);
20510
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20511 {
20512
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3293 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3293 times.
3293 msg_it->set_buffer("");
20513 // Advance the iterator to run many commands in one frame.
20514
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20515
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20516 3293 }
20517 else
20518 {
20519
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20520
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20522 6 msg_it->post_segment_delay = 1;
20523 }
20524 3299 }
20525
20526
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236458 times.
239635 if (msg_it->state == MsgStr::iterator::CHARACTER)
20527 {
20528
1/2
✓ Branch 0 taken 236458 times.
✗ Branch 1 not taken.
236458 if (!putmsgchar(play_sfx)) return msg_tick_break;
20529 236458 }
20530 239635 }
20531
20532 241666 bool wait_advance_check_early = !burst_mode;
20533
20534
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163177 times.
241666 if (wait_advance_check_early)
20535 {
20536
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163176 times.
163177 if (do_end_str)
20537 {
20538 1 msg_tick_end();
20539 1 return msg_tick_exit;
20540 }
20541
20542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163176 times.
163176 if (wait_advance)
20543 {
20544 msg_it->next();
20545 return msg_tick_exit;
20546 }
20547 163176 }
20548
20549
2/2
✓ Branch 0 taken 239629 times.
✓ Branch 1 taken 2036 times.
241665 if (do_run_menu)
20550 {
20551
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20552 {
20553 5 do_run_menu = false;
20554
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20555 {
20556 2 msg_it->next();
20557 2 return msg_tick(play_sfx, burst_mode);
20558 }
20559 3 }
20560 2031 else return msg_tick_break;
20561 3 }
20562
20563 239632 msg_it->next();
20564
20565
2/2
✓ Branch 0 taken 161677 times.
✓ Branch 1 taken 77955 times.
239632 if (!wait_advance_check_early)
20566 {
20567
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20568 {
20569 2 msg_tick_end();
20570 2 return msg_tick_exit;
20571 }
20572
20573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20574 return msg_tick_exit;
20575 77953 }
20576
20577
4/4
✓ Branch 0 taken 4004 times.
✓ Branch 1 taken 235626 times.
✓ Branch 2 taken 1987 times.
✓ Branch 3 taken 2017 times.
239630 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20578 {
20579
1/2
✓ Branch 0 taken 2017 times.
✗ Branch 1 not taken.
2017 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20580 setmsg(MsgStrings[msgstr].nextstring);
20581 2017 }
20582
20583 239630 return msg_tick_continue;
20584 241666 }
20585
20586 165464 static void msg_tick_end(bool disappear)
20587 {
20588
2/2
✓ Branch 0 taken 164451 times.
✓ Branch 1 taken 1013 times.
165464 if (disappear)
20589 1013 goto disappear;
20590
20591 // Done printing the string
20592
8/8
✓ Branch 0 taken 164448 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 162951 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 158928 times.
✓ Branch 5 taken 4023 times.
✓ Branch 6 taken 158928 times.
✓ Branch 7 taken 4023 times.
164451 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20593 {
20594
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4023 times.
4026 if(!do_end_str)
20595 {
20596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4023 times.
4023 while (msg_it->state == MsgStr::iterator::COMMAND)
20597 {
20598 parsemsgcode2(msg_it->command);
20599 msg_it->next();
20600 }
20601 4023 }
20602
20603 // Go to next string, or make it disappear by going to string 0.
20604
5/6
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 993 times.
✓ Branch 3 taken 1014 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 993 times.
4026 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20605 {
20606 3033 linkedmsgclk=do_end_str?1:51;
20607 3033 }
20608
20609
2/2
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 2019 times.
4026 if(MsgStrings[msgstr].nextstring==0)
20610 {
20611
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 993 times.
2007 if(!get_qr(qr_MSGDISAPPEAR))
20612 993 {
20613 disappear:
20614 2006 msg_active = false;
20615 2006 Hero.finishedmsg();
20616 2006 }
20617
20618
2/2
✓ Branch 0 taken 3007 times.
✓ Branch 1 taken 13 times.
3020 if(repaircharge)
20619 {
20620
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20621 13 repaircharge = 0;
20622 13 }
20623
20624
2/2
✓ Branch 0 taken 3018 times.
✓ Branch 1 taken 2 times.
3020 if(adjustmagic)
20625 {
20626
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20627 {
20628
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20629 2 game->set_magicdrainrate(1);
20630 2 }
20631 else if(game->get_magicdrainrate() > 1)
20632 {
20633 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20634 }
20635 2 adjustmagic = false;
20636 2 sfx(WAV_SCALE);
20637
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20638 2 }
20639
20640
2/2
✓ Branch 0 taken 3018 times.
✓ Branch 1 taken 2 times.
3020 if(learnslash)
20641 {
20642 2 game->set_canslash(1);
20643 2 learnslash = false;
20644 2 sfx(WAV_SCALE);
20645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20646 2 }
20647 3020 }
20648 5039 }
20649 165464 }
20650
20651 6222 static void msg_consume_spaces()
20652 {
20653
2/2
✓ Branch 0 taken 6222 times.
✓ Branch 1 taken 16095 times.
22317 while (msg_it->character == " ")
20654 {
20655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16095 times.
16095 if (!putmsgchar(false)) break;
20656
20657 // Advance the iterator.
20658 16095 msg_it->next();
20659
20660 // The "Continue From Previous" feature
20661
1/2
✓ Branch 0 taken 16095 times.
✗ Branch 1 not taken.
16095 if (msg_it->state == MsgStr::iterator::DONE)
20662 {
20663 if(MsgStrings[msgstr].nextstring)
20664 {
20665 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20666 {
20667 setmsg(MsgStrings[msgstr].nextstring);
20668 }
20669 }
20670 }
20671 }
20672 6222 }
20673
20674 14545844 void putmsg()
20675 {
20676
2/2
✓ Branch 0 taken 681152 times.
✓ Branch 1 taken 13864692 times.
14545844 if(!msgorig) msgorig=msgstr;
20677
20678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14545844 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14545844 if(wait_advance && linkedmsgclk < 1)
20679 linkedmsgclk = 1;
20680
2/2
✓ Branch 0 taken 14267664 times.
✓ Branch 1 taken 278180 times.
14545844 if(linkedmsgclk>0)
20681 {
20682
2/2
✓ Branch 0 taken 126729 times.
✓ Branch 1 taken 151451 times.
278180 if(linkedmsgclk==1)
20683 {
20684
6/6
✓ Branch 0 taken 126726 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123816 times.
✓ Branch 3 taken 2910 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123698 times.
126729 if(do_end_str||cAbtn()||cBbtn())
20685 {
20686 3031 do_end_str = false;
20687 3031 linkedmsgclk = 0;
20688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if(wait_advance)
20689 {
20690 wait_advance = false;
20691 }
20692 else
20693 {
20694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if (!msgscr) msgscr = hero_scr;
20695 3031 msgstr=MsgStrings[msgstr].nextstring;
20696 3031 ssc_tile_hei_buf = -1;
20697
3/4
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
✓ Branch 2 taken 1013 times.
✗ Branch 3 not taken.
3031 if(!msgstr && enqueued_str)
20698 {
20699 msgstr = enqueued_str;
20700 enqueued_str = 0;
20701 }
20702
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
3031 if(!msgstr)
20703 {
20704 1013 msgfont=get_zc_font(font_zfont);
20705
20706
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1009 times.
1013 if(msgscr->room!=rGRUMBLE)
20707 1009 blockpath=false;
20708
20709 1013 dismissmsg();
20710 1013 msg_tick_end(true);
20711 1013 return;
20712 }
20713
20714 2018 donewmsg(msgscr, msgstr);
20715 2018 putprices(false);
20716 }
20717 2018 }
20718 125716 }
20719 else
20720 {
20721 151451 --linkedmsgclk;
20722 }
20723 277167 }
20724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14544831 times.
14544831 if(wait_advance) return; //Waiting for buttonpress
20725
20726
9/10
✓ Branch 0 taken 14542876 times.
✓ Branch 1 taken 1955 times.
✓ Branch 2 taken 676224 times.
✓ Branch 3 taken 13866652 times.
✓ Branch 4 taken 263270 times.
✓ Branch 5 taken 412954 times.
✓ Branch 6 taken 259248 times.
✓ Branch 7 taken 4022 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 259248 times.
14544831 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20727 {
20728
2/2
✓ Branch 0 taken 13866652 times.
✓ Branch 1 taken 416976 times.
14283628 if(!msgstr)
20729 13866652 msgorig=0;
20730
20731 14283628 msg_active = false;
20732 14283628 msg_it.reset();
20733 14283628 return;
20734 }
20735
20736
1/2
✓ Branch 0 taken 261203 times.
✗ Branch 1 not taken.
261203 if (!msg_it)
20737 return;
20738
20739 261203 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20740
20741
2/2
✓ Branch 0 taken 257157 times.
✓ Branch 1 taken 4046 times.
261203 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20742 {
20743 4046 msg_it->next();
20744 4046 msg_consume_spaces();
20745 4046 }
20746
20747 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20748 // as possible. This skips the character-by-character animation that usually renders a string
20749 // slowly over many frames.
20750
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 259822 times.
✓ Branch 2 taken 897 times.
✓ Branch 3 taken 258925 times.
261203 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20751 {
20752
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
80231 while (!msg_it->done())
20753 {
20754
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20755 10 goto breakout; // break out if message speed was changed to non-zero
20756
20757 78489 auto tick = msg_tick(msg_it->character != " ", true);
20758
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20759 534 break;
20760
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20761 2 return;
20762 }
20763
20764
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20765 {
20766 1274 msgclk = 72;
20767 1274 }
20768 1808 }
20769 else
20770 258925 {
20771 breakout:
20772 258935 word tempspeed = msgspeed;
20773
2/2
✓ Branch 0 taken 257972 times.
✓ Branch 1 taken 963 times.
258935 if (do_run_menu)
20774 963 tempspeed = 0;
20775
6/6
✓ Branch 0 taken 207701 times.
✓ Branch 1 taken 51234 times.
✓ Branch 2 taken 121484 times.
✓ Branch 3 taken 86217 times.
✓ Branch 4 taken 111407 times.
✓ Branch 5 taken 10077 times.
258935 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20776 96294 return;
20777 }
20778
20779 // Process the next msg tick.
20780 // This will either print a single character, or process a single string command (with one
20781 // exception).
20782
3/4
✓ Branch 0 taken 163175 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163175 times.
164449 if (!msg_it->done() && !bottom_margin_clip())
20783 {
20784 // This may run an additional tick in the case of a string menu finishing: the first
20785 // tick wraps up the menu, and then a second tick processes the next character or command.
20786 163175 auto tick = msg_tick(true, false);
20787
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161678 times.
163175 if (tick == msg_tick_break)
20788 {
20789 1497 msg_tick_end();
20790 1497 return;
20791 }
20792
2/2
✓ Branch 0 taken 161677 times.
✓ Branch 1 taken 1 times.
161678 if (tick == msg_tick_exit)
20793 1 return;
20794
20795 // If the next two characters are spaces, consume all upcoming spaces now.
20796
13/20
✓ Branch 0 taken 2749 times.
✓ Branch 1 taken 158928 times.
✓ Branch 2 taken 158928 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26234 times.
✓ Branch 5 taken 132694 times.
✓ Branch 6 taken 26234 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26234 times.
✓ Branch 10 taken 135443 times.
✓ Branch 11 taken 26234 times.
✓ Branch 12 taken 2749 times.
✓ Branch 13 taken 158928 times.
✓ Branch 14 taken 159501 times.
✓ Branch 15 taken 2176 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
187911 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20797 2176 msg_consume_spaces();
20798 161677 }
20799
20800 162951 msg_tick_end();
20801 14545386 }
20802
20803 124732 int32_t message_more_y()
20804 {
20805 //Is the flag ticked, do we really want a message more y larger than 160?
20806
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124704 times.
✓ Branch 2 taken 124732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124704 times.
✓ Branch 5 taken 28 times.
124732 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20807 124732 msgy+=playing_field_offset;
20808 124732 return msgy;
20809 }
20810
20811 /*** Collision detection & handling ***/
20812
20813 14233887 void clear_script_one_frame_conditions()
20814 {
20815
2/2
✓ Branch 0 taken 38818785 times.
✓ Branch 1 taken 14233887 times.
53052672 for(int32_t j=0; j<guys.Count(); j++)
20816 {
20817 38818785 enemy *e = (enemy*)guys.spr(j);
20818
2/2
✓ Branch 0 taken 659919345 times.
✓ Branch 1 taken 38818785 times.
698738130 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20819 38818785 }
20820 14233887 }
20821
20822 4869426 void check_enemy_lweapon_collision(weapon *w)
20823 {
20824
8/8
✓ Branch 0 taken 4254598 times.
✓ Branch 1 taken 614828 times.
✓ Branch 2 taken 3263510 times.
✓ Branch 3 taken 991088 times.
✓ Branch 4 taken 3203206 times.
✓ Branch 5 taken 60304 times.
✓ Branch 6 taken 16720 times.
✓ Branch 7 taken 3186486 times.
4869426 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20825 {
20826
2/2
✓ Branch 0 taken 3170737 times.
✓ Branch 1 taken 11196743 times.
14367480 for(int32_t j=0; j<guys.Count(); j++)
20827 {
20828 11196743 enemy *e = (enemy*)guys.spr(j);
20829
20830 11196743 bool didhit = e->hit(w);
20831 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20832 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20833
2/2
✓ Branch 0 taken 10976162 times.
✓ Branch 1 taken 220581 times.
11196743 if(didhit)
20834 {
20835 // !(e->stunclk)
20836 220581 int32_t h = e->takehit(w);
20837
2/2
✓ Branch 0 taken 186775 times.
✓ Branch 1 taken 33806 times.
220581 if (h < 0) // hitby code
20838 {
20839 33806 int indx = Lwpns.find(w);
20840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33806 times.
33806 if(indx > -1)
20841 33806 e->hitby[HIT_BY_LWEAPON] = indx+1;
20842 33806 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20843 33806 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20844
2/2
✓ Branch 0 taken 31418 times.
✓ Branch 1 taken 2388 times.
33806 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
20845 2388 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20846 33806 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20847 33806 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20848 //we may need to handle this in special cases. -Z
20849 // arrow item pierce flag, for example -Em
20850 33806 }
20851
20852
2/2
✓ Branch 0 taken 33806 times.
✓ Branch 1 taken 186775 times.
220581 if(h < 0) // hit, check if weapon is "out of pierces"
20853 33806 w->hit_pierce(e, h);
20854
2/2
✓ Branch 0 taken 176400 times.
✓ Branch 1 taken 10375 times.
186775 else if(h > 0) // blocked
20855 10375 w->onhit(false, e, h);
20856
2/2
✓ Branch 0 taken 217907 times.
✓ Branch 1 taken 2674 times.
220581 if(abs(h) == 2)
20857 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
20858 217907 }
20859
20860
2/2
✓ Branch 0 taken 11180994 times.
✓ Branch 1 taken 13075 times.
11194069 if(w->Dead())
20861 {
20862 13075 break;
20863 }
20864 11180994 }
20865
20866 // Item flags added in 2.55:
20867 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20868 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20869 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20870 // -Em
20871
6/6
✓ Branch 0 taken 2731943 times.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 2687932 times.
✓ Branch 3 taken 44011 times.
✓ Branch 4 taken 44752 times.
✓ Branch 5 taken 2643180 times.
3186486 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20872 {
20873 543306 int32_t itype, pitem = w->parentitem;
20874
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 44752 times.
✓ Branch 3 taken 44011 times.
543306 switch(w->id)
20875 {
20876 454543 case wBrang: itype = itype_brang; break;
20877 44752 case wArrow: itype = itype_arrow; break;
20878 case wHookshot:
20879 44011 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20880 44011 break;
20881 }
20882
2/2
✓ Branch 0 taken 538265 times.
✓ Branch 1 taken 5041 times.
543306 if(pitem < 0) pitem = current_item_id(itype);
20883
5/6
✓ Branch 0 taken 44011 times.
✓ Branch 1 taken 499295 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 43911 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
543306 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20884 { //Swap with item
20885 for(int32_t j=0; j<items.Count(); j++)
20886 {
20887 if(items.spr(j)->hit(w))
20888 {
20889 item *theItem = ((item*)items.spr(j));
20890 bool priced = theItem->PriceIndex >-1;
20891 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20892 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20893 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20894 {
20895 if(!Hero.switchhookclk)
20896 {
20897 hooked_comborpos = rpos_t::None;
20898 hooked_layerbits = 0;
20899 switching_object = theItem;
20900 theItem->switch_hooked = true;
20901 w->misc = 2;
20902 w->step = 0;
20903 theItem->clk2=256;
20904 Hero.doSwitchHook(game->get_switchhookstyle());
20905 if(QMisc.miscsfx[sfxSWITCHED])
20906 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
20907 }
20908 }
20909 }
20910 }
20911 }
20912
6/6
✓ Branch 0 taken 44752 times.
✓ Branch 1 taken 498554 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 330187 times.
✓ Branch 4 taken 498554 times.
✓ Branch 5 taken 330187 times.
543306 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20913 {
20914
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
20915 {
20916
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
20917 {
20918 4898 item *theItem = ((item*)items.spr(j));
20919 4898 bool priced = theItem->PriceIndex >-1;
20920
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20921
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20922
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
20923 {
20924
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
20925 {
20926 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
20927 }
20928
20929 1724 Hero.checkitems(j);
20930 1724 }
20931 4898 }
20932 88886 }
20933 374939 }
20934
2/2
✓ Branch 0 taken 15661 times.
✓ Branch 1 taken 152706 times.
828741 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
20935 {
20936
2/2
✓ Branch 0 taken 36622 times.
✓ Branch 1 taken 152706 times.
189328 for(int32_t j=0; j<items.Count(); j++)
20937 {
20938
2/2
✓ Branch 0 taken 27979 times.
✓ Branch 1 taken 8643 times.
36622 if(items.spr(j)->hit(w))
20939 {
20940 8643 item *theItem = ((item*)items.spr(j));
20941 8643 bool priced = theItem->PriceIndex >-1;
20942
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8636 times.
8643 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20943
4/6
✓ Branch 0 taken 8643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8643 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8409 times.
✓ Branch 5 taken 234 times.
8643 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20944
5/10
✓ Branch 0 taken 7228 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8643 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20945 {
20946 7228 int32_t pickup = theItem->pickup;
20947 7228 int32_t id2 = theItem->id;
20948 7228 int32_t pstr = theItem->pstring;
20949 7228 int32_t pstr_flags = theItem->pickup_string_flags;
20950
20951 7228 std::vector<int32_t> &ev = FFCore.eventData;
20952 7228 ev.clear();
20953 7228 ev.push_back(id2*10000);
20954 7228 ev.push_back(pickup*10000);
20955 7228 ev.push_back(pstr*10000);
20956 7228 ev.push_back(pstr_flags*10000);
20957 7228 ev.push_back(0);
20958 7228 ev.push_back(theItem->getUID());
20959 7228 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
20960 7228 ev.push_back(w->getUID());
20961
20962 7228 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
20963 7228 bool nullify = ev[4] != 0;
20964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7228 times.
7228 if(nullify) continue;
20965
2/2
✓ Branch 0 taken 1031 times.
✓ Branch 1 taken 6197 times.
7228 if(w->id == wBrang)
20966 {
20967 6197 w->onhit(false);
20968 6197 }
20969
20970
2/2
✓ Branch 0 taken 6735 times.
✓ Branch 1 taken 493 times.
7228 if(w->dragging==-1)
20971 {
20972 493 w->dead=1;
20973 493 theItem->clk2=256;
20974 493 w->dragging=j;
20975 493 theItem->is_dragged = true;
20976 493 }
20977 7228 }
20978 8643 }
20979 36622 }
20980 152706 }
20981 543306 }
20982 3186486 }
20983 4869426 }
20984 14231704 void check_collisions()
20985 {
20986
2/2
✓ Branch 0 taken 4869391 times.
✓ Branch 1 taken 14231704 times.
19101095 for(uint q = 0; q < Lwpns.Count(); ++q)
20987 4869391 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
20988 14231704 }
20989
20990 14233887 void dragging_item()
20991 {
20992
2/2
✓ Branch 0 taken 4985554 times.
✓ Branch 1 taken 14233887 times.
19219441 for(int32_t i=0; i<Lwpns.Count(); i++)
20993 {
20994 4985554 weapon *w = (weapon*)Lwpns.spr(i);
20995
20996
4/4
✓ Branch 0 taken 4522416 times.
✓ Branch 1 taken 463138 times.
✓ Branch 2 taken 4830872 times.
✓ Branch 3 taken 154682 times.
4985554 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
20997 {
20998
3/4
✓ Branch 0 taken 7202 times.
✓ Branch 1 taken 147480 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7202 times.
154682 if(w->dragging>=0 && w->dragging<items.Count())
20999 {
21000 7202 item* dragItem = (item*)items.spr(w->dragging);
21001 7202 dragItem->x=w->x;
21002 7202 dragItem->y=w->y;
21003
21004 // Drag the Fairy enemy as well as the Fairy item
21005 7202 int32_t id = dragItem->id;
21006
21007
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6783 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7202 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21008 {
21009 404 movefairynew2(w->x,w->y,*dragItem);
21010 404 }
21011 7202 }
21012 154682 }
21013 4985554 }
21014 14233887 }
21015
21016 57 int32_t more_carried_items(int screen)
21017 {
21018 57 int32_t hasmorecarries = 0;
21019
21020
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
21021 {
21022 64 auto spr = (item*)items.spr(i);
21023
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21024 {
21025 57 hasmorecarries++;
21026 57 }
21027 64 }
21028
21029 57 return hasmorecarries;
21030 }
21031
21032 36535 static int count_guys_from_screen(int screen)
21033 {
21034 36535 int count = 0;
21035
2/2
✓ Branch 0 taken 237871 times.
✓ Branch 1 taken 36535 times.
274406 for (int i=0; i < guys.Count(); i++)
21036 {
21037
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 201333 times.
237871 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21038 201333 count += 1;
21039 237871 }
21040 36535 return count;
21041 }
21042
21043 // messy code to do the enemy-carrying-the-item thing
21044 14621815 static void roaming_item(mapscr* scr)
21045 {
21046 14621815 int screen = scr->screen;
21047 14621815 auto& state = get_screen_state(screen);
21048
4/4
✓ Branch 0 taken 14585342 times.
✓ Branch 1 taken 36473 times.
✓ Branch 2 taken 14585280 times.
✓ Branch 3 taken 36535 times.
14621815 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21049 14585280 return;
21050
21051 // All enemies already dead upon entering a room?
21052
1/2
✓ Branch 0 taken 36535 times.
✗ Branch 1 not taken.
36535 if (count_guys_from_screen(screen) == 0)
21053 {
21054 return;
21055 }
21056
21057 36535 int guycarryingitem = -1;
21058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84544 times.
84544 for(int32_t j=0; j<guys.Count(); j++)
21059 {
21060 84544 enemy* e = (enemy*)guys.spr(j);
21061
4/4
✓ Branch 0 taken 62850 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36535 times.
84544 if (e->screen_spawned == screen && e->itemguy)
21062 {
21063 36535 guycarryingitem=j;
21064 36535 break;
21065 }
21066 48009 }
21067
21068
2/2
✓ Branch 0 taken 36458 times.
✓ Branch 1 taken 77 times.
36535 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21069 {
21070
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(guycarryingitem == -1) //This happens when "default enemies" such as
21071 {
21072 return; //eSHOOTFBALL are alive but enemies from the list
21073 } //are not. Defer to HeroClass::checkspecial().
21074
21075 77 int32_t Item=scr->item;
21076
21077 77 state.item_state = ScreenItemState::None;
21078
21079
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21080 {
21081 154 auto [x, y] = translate_screen_coordinates_to_world(screen);
21082 218 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21083
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 13 times.
77 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21084 );
21085 77 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21086 77 state.item_state = ScreenItemState::CarriedByEnemy;
21087 77 }
21088 else
21089 {
21090 return;
21091 }
21092 77 }
21093
21094
2/2
✓ Branch 0 taken 46044 times.
✓ Branch 1 taken 36535 times.
82579 for(int32_t i=0; i<items.Count(); i++)
21095 {
21096
4/4
✓ Branch 0 taken 42433 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36535 times.
46044 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21097 {
21098
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 14295 times.
36535 if(get_qr(qr_HIDECARRIEDITEMS))
21099 {
21100 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21101 22240 items.spr(i)->y = -128;
21102 22240 }
21103
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21104 {
21105
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21106 {
21107 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21108 {
21109 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21110 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21111 }
21112 else
21113 {
21114 if(guys.spr(guycarryingitem)->extend >= 3)
21115 {
21116 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21117 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21118 }
21119 else
21120 {
21121 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21122 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21123 }
21124 }
21125 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21126 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21127 }
21128 else
21129 {
21130 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21131 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21132 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21133 }
21134 14295 }
21135 36535 }
21136 46044 }
21137 14621815 }
21138
21139 14233887 void roaming_item()
21140 {
21141 28855702 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21142 14621815 roaming_item(scr);
21143 14621815 });
21144 14233887 }
21145
21146 bool enemy::IsBigAnim()
21147 {
21148 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21149 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21150 || anim == a4FRM8DIRB);
21151 }
21152 2405420 int32_t enemy::getFlashingCSet()
21153 {
21154 //Special cset for the dying sprite
21155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2405420 times.
2405420 if(dying)
21156 {
21157 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21158 return wpnsbuf[spr_death].csets & 15;
21159 else
21160 return (((clk2 + 5) >> 1) & 3) + 6;
21161 }
21162
21163 //Normal cset
21164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2405420 times.
2405420 if (hclk <= 0)
21165 {
21166 //Special cset for the flashing animation
21167 if (flags & guy_flashing)
21168 return (frame & 3) + 6;
21169 return cs;
21170 }
21171
21172 //Hurt animations
21173
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2401532 times.
2405420 if(family==eeGANON)
21174 3888 return (((hclk-1)>>1)&3)+6;
21175
4/4
✓ Branch 0 taken 2232436 times.
✓ Branch 1 taken 169096 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1745298 times.
2401532 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21176 1745298 return (((hclk-1)>>1)&3)+6;
21177
21178 656234 return cs;
21179 2405420 }
21180
21181 81632866 bool enemy::is_hitflickerframe(bool olddrawing)
21182 {
21183
6/6
✓ Branch 0 taken 81604362 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3953574 times.
✓ Branch 3 taken 77650788 times.
✓ Branch 4 taken 3180883 times.
✓ Branch 5 taken 772691 times.
81632866 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21184 80860175 return false;
21185
21186
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21187 return false;
21188
21189 772691 int32_t fr = game->get_spriteflickerspeed();
21190
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21191 return true;
21192 772691 return frame % (fr * 2) < fr;
21193 81632866 }
21194
21195 const char *old_guy_string[OLDMAXGUYS] =
21196 {
21197 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21198 // 020
21199 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21200 // 025
21201 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21202 // 030
21203 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21204 // 035
21205 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21206 // 040
21207 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21208 // 045
21209 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21210 // 050
21211 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21212 // 055
21213 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21214 // 060
21215 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21216 // 065
21217 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21218 // 070
21219 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21220 // 075
21221 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21222 // 080
21223 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21224 // 085
21225 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21226 // 090
21227 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21228 // 095
21229 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21230 // 100
21231 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21232 // 105
21233 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21234 // 110
21235 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21236 // 115
21237 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21238 // 120
21239 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21240 // 125
21241 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21242 // 130
21243 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21244 // 135
21245 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21246 // 140
21247 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21248 // 145
21249 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21250 // 150
21251 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21252 // 155
21253 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21254 // 160
21255 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21256 // 165
21257 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21258 // 170
21259 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21260 // 175
21261 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21262 };
21263
21264 15687886 int32_t enemy::get_dmisc(byte index)
21265 {
21266
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 15885 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1794 times.
✓ Branch 6 taken 1051 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 1852 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 7793452 times.
✓ Branch 11 taken 7597384 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
15687886 switch (index)
21267 {
21268 14611 case 0: return dmisc1;
21269 15885 case 1: return dmisc2;
21270 3236 case 2: return dmisc3;
21271 7390 case 3: return dmisc4;
21272 2144 case 4: return dmisc5;
21273 1794 case 5: return dmisc6;
21274 1051 case 6: return dmisc7;
21275 250 case 7: return dmisc8;
21276 1852 case 8: return dmisc9;
21277 1822 case 9: return dmisc10;
21278 7793452 case 10: return dmisc11;
21279 7597384 case 11: return dmisc12;
21280 case 12: return dmisc13;
21281 308 case 13: return dmisc14;
21282 case 14: return dmisc15;
21283 40 case 15: return dmisc16;
21284 case 16: return dmisc17;
21285 216 case 17: return dmisc18;
21286 case 18: return dmisc19;
21287 case 19: return dmisc20;
21288 case 20: return dmisc21;
21289 case 21: return dmisc22;
21290 case 22: return dmisc23;
21291 case 23: return dmisc24;
21292 884 case 24: return dmisc25;
21293 1120 case 25: return dmisc26;
21294 331 case 26: return dmisc27;
21295 238061 case 27: return dmisc28;
21296 case 28: return dmisc29;
21297 case 29: return dmisc30;
21298 case 30: return dmisc31;
21299 6055 case 31: return dmisc32;
21300 }
21301
21302 return 0;
21303 15687886 }
21304
21305 312 void enemy::set_dmisc(byte index, int32_t value)
21306 {
21307
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21308 {
21309 case 0: dmisc1 = value; break;
21310 case 1: dmisc2 = value; break;
21311 case 2: dmisc3 = value; break;
21312 case 3: dmisc4 = value; break;
21313 case 4: dmisc5 = value; break;
21314 case 5: dmisc6 = value; break;
21315 case 6: dmisc7 = value; break;
21316 case 7: dmisc8 = value; break;
21317 case 8: dmisc9 = value; break;
21318 case 9: dmisc10 = value; break;
21319 case 10: dmisc11 = value; break;
21320 case 11: dmisc12 = value; break;
21321 case 12: dmisc13 = value; break;
21322 case 13: dmisc14 = value; break;
21323 case 14: dmisc15 = value; break;
21324 case 15: dmisc16 = value; break;
21325 case 16: dmisc17 = value; break;
21326 case 17: dmisc18 = value; break;
21327 case 18: dmisc19 = value; break;
21328 case 19: dmisc20 = value; break;
21329 case 20: dmisc21 = value; break;
21330 case 21: dmisc22 = value; break;
21331 case 22: dmisc23 = value; break;
21332 case 23: dmisc24 = value; break;
21333 case 24: dmisc25 = value; break;
21334 case 25: dmisc26 = value; break;
21335 4 case 26: dmisc27 = value; break;
21336 24 case 27: dmisc28 = value; break;
21337 case 28: dmisc28 = value; break;
21338 case 29: dmisc30 = value; break;
21339 case 30: dmisc31 = value; break;
21340 284 case 31: dmisc32 = value; break;
21341 }
21342 312 }
21343